The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
upper limit of accessible memory space for a single process in Unix/Linux cy163 UNIX for Dummies Questions & Answers 1 04-30-2007 07:09 AM
Process using the most memory janet AIX 5 03-22-2006 03:33 AM
Memory in Use by a process khopdi Shell Programming and Scripting 0 10-18-2005 11:59 AM
Memory used by a process luft UNIX for Dummies Questions & Answers 3 08-18-2005 03:27 PM
Memory used by a particular process superprogrammer UNIX for Dummies Questions & Answers 3 06-11-2005 10:51 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 06-10-2008
Registered User
 

Join Date: Jun 2008
Posts: 2
process memory change in unix

Hello! I was wondering if I could trouble all your experts with a couple questions regarding checking memory usage changes during the run time in the specific program (process) under UNIX.
1. After the program starts running, is ps the best way to tell the total memory usage at the any time?

2. If the malloc command is used in that program, for example total 50MB malloc is called, will the memory of the program be increased by 50 MB?

3. If the free command is used after the malloc command, for example 20MB is freed, will the memory usage is decreased by 20MB? Can other program start using that freed memory.

Thanks so much!
Reply With Quote
Forum Sponsor
  #2  
Old 06-11-2008
...@...
 

Join Date: Feb 2004
Location: NM
Posts: 4,298
1. top works.
Code:
#assume  process pid you want is 2350
 top -n 5000 -f t.lis
 grep 2350 t.lis
2. changes from malloc will be reflected in the display

3.
This requires more of an answer. To get memory for malloc to work with, especially 50MB chunks, the OS has to call brk() on behalf of the process. brk() maps more memory for the data segment into the process. Since brk() is an expensive call and you have to call brk() with a negative argument to "give memory back" most OS's do not do that. This is on the assumption that if the program called for that chunk of memory it may be called for again in the future. So, processes do not normally "shrink" during runtime.
Reply With Quote
  #3  
Old 06-12-2008
Registered User
 

Join Date: Jun 2008
Posts: 2
Smile

I understand now. Thank you very much for your detailed explanation.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 02:45 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0