Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
28591 Discussions

how can I know the allocated memory size of my program

Chang_Lei
Beginner
592 Views
As the title,how can I know the allocated memory size of my program? Especially when compiling it.
Is there any compile option can be used, or any other method can tell me the allocatedmemory size?
The system environment is Intel XeonE5450,16GB memory,Redhat Enterprise Linux 5.2,Intel Fortran Compiler 10.1.
Thanks!
0 Kudos
1 Solution
mecej4
Honored Contributor III
592 Views
There are two different measures related to your question. One is the static memory needed (code, data) and the other is the size of the dynamically allocated memory, the latter of which can vary during the course of execution and may depend on the input data.

For reporting the static memory needed, use the size command (e.g., size ./a.out).

For monitoring dynamic memory usage, there are several utilities used by system administrators that monitor consumption of various resources.

View solution in original post

0 Kudos
6 Replies
mecej4
Honored Contributor III
593 Views
There are two different measures related to your question. One is the static memory needed (code, data) and the other is the size of the dynamically allocated memory, the latter of which can vary during the course of execution and may depend on the input data.

For reporting the static memory needed, use the size command (e.g., size ./a.out).

For monitoring dynamic memory usage, there are several utilities used by system administrators that monitor consumption of various resources.
0 Kudos
Chang_Lei
Beginner
592 Views
That works. Thanks.

I noted that when my dynamic memory usage exceed systemmax memory size, the program was killed. Is it killed by system? Why does thevirtual memory not be used to run the program?
Could you please provide some suggestions?
0 Kudos
jimdempseyatthecove
Honored Contributor III
592 Views
In Linux there is a process called OOM. The intention of OOM is to kill runaway applications. Unfortunately, it will also kill applicaions such as yours. See: http://linux-mm.org/OOM_Killer

Hint:
Any particular process leader may be immunized against the oom killer if the value of its /proc//oomadj is set to the constant OOM_DISABLE (currently defined as -17).

Jim Dempsey
0 Kudos
Ron_Green
Moderator
592 Views
one other note about this: the virtual memory system is being used by linux. There is a misconception that because you have VM and 64bit addressing that you can allocate enormous memory structures. This is not true, there are limits to what your VM can do. That limit has an absolute ceiling of ( size of RAM ) + ( size of swap ). In practice, I aim for around 80% of that limit for my applications, leaving 20% for IO buffers, MPI buffers, and system overhead.
As an example, if you have 4GB of RAM and a 1GB swap partition, you absolutely cannot exceed 5GB total memory allocation but in practice you might limit your application to .8 * 5GB = 4GB maximum.
Other folks would limit their application to less than physical memory to avoid paging and potential swapping.
ron
0 Kudos
Chang_Lei
Beginner
592 Views
Thanks all.
There are so much knowledges to be learn.
0 Kudos
jimdempseyatthecove
Honored Contributor III
592 Views
Ron,

When yourdata hoggingapplication runs through localized sections of data then you might consider using a swap file that is several times larger than physical RAM. e.g. 4GB RAM with 16GB... 100GB swap file. While you can get by with using lesser memory with use of data file(s), often it is easier to program as if you have "unlimited" memory.

Random (or sequential) file read/writes may be preferred, but this may require some management code. Using additional Virtual Memory in excess of RAM can eliminate the management code. Additionaly, paging is generally more efficient than file I/O and deffinately more efficient than file open, R/W, file close. If your system permits, using a memory mapped file may be a better choice since you can checkpoint the Virtual Memory (file) and use it for interprocess communication.

Jim Dempsey
0 Kudos
Reply