Solved

How to find the memory usage of a multithreaded process (on AIX)!?

Posted on 2001-06-26
8
2,052 Views
Last Modified: 2013-12-06
Hi,

I have this program which runs for days and allocates a lot of RAM. Often I start getting No-Memory errors in the program (new() failed) even when programs like "top" or "ps" show the memory usage to be less than available memory.  I would like a way to let the program figure out it's own memory usage, and if possible , the maximum amount of memory it can allocate at any point of time.

The program is compiled as a 32 bit executable on a 64 bit AIX 4.3 machine. The available memory is 12Gb, my program starts having failed new() allcoations around 1.4Gb (close to but not yet at the 2Gb limit for the 32 but program).

Any help at all would be welcome. Any insights into how 32 bit programs memory allocation is dealt with in a 64 but enviro !?
0
Comment
Question by:ngoel
8 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 6229867
How much swap is available? Typically on a Unix OS the kernel will use brk() to swap out the task when it is necessary to increase the in-core size of the task as memory is allocated by malloc(). Because brk() is expensive, a sizeable chunk (much larger than the outstanding malloc()) is allocated. So if swap isn't large enough to hold the task and any other swapped out tasks you'll get the "out of memory error" even when there is free memory on the system when the kernel needs to increase the size of the task.
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 6232735
Also what about ulimit -m (memory any one process is allowed)?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6241199
did you check with vmstat?
0
 

Author Comment

by:ngoel
ID: 6266942
ulimit is not a problem, my 32 bit application can theoretically allocate 2Gb and small test applications on that system actually allow a "new" of that size.

Actually for some reasons, I am not sure that the OS is reporting the correct memory usage (through PS or TOP), that is why I wanted some way of figuring out memory usage from *within* the program itself. Is there any way ?

Moreover, there is plenty of swap space (there is even tons of real memory available) because as I said, I am running this on a 64 bit machine with tons of ram and swap space, my 32 bit application cannot even physically address all that RAM available.

So if there was some way of seeing the available memory from the process's eyes (whatever way the 32bit emulation works), then I would like to know.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 14

Expert Comment

by:chris_calabrese
ID: 6269228
sbrk(0) will return the current max addressible location for the process.  That doesn't mean you actually get to use that whole mem space, though, since it's laid out with some bits set aside for the stack, some for shated memory segments, some for memory mapped files, etc.  You can easily hit the 2gb limit without having 2gb of usable memory for your process.
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10329502
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

PAQ with points refunded

Please leave any comments here within the next four days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10329517
I would have expected to see an answer that spoke specifically about the memory model used for 32-bit applications on AIX.
0
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 10361320
PAQed, with points refunded (300)

Computer101
E-E Admin
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In tuning file systems on the Solaris Operating System, changing some parameters of a file system usually destroys the data on it. For instance, changing the cache segment block size in the volume of a T3 requires that you delete the existing volu…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now