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

Posted on 2001-06-26
Last Modified: 2013-12-06

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 !?
Question by:ngoel
LVL 40

Expert Comment

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.
LVL 14

Expert Comment

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

Expert Comment

ID: 6241199
did you check with vmstat?
NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud


Author Comment

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.
LVL 14

Expert Comment

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.
LVL 20

Expert Comment

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.

EE Cleanup Volunteer
LVL 20

Expert Comment

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

Accepted Solution

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

E-E Admin

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Suggested Solutions

A metadevice consists of one or more devices (slices). It can be expanded by adding slices. Then, it can be grown to fill a larger space while the file system is in use. However, not all UNIX file systems (UFS) can be expanded this way. The conca…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (…
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…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

810 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