- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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!
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
Link Copied
6 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
Hint:
Any particular process leader may be immunized against the oom killer if the value of its /proc/
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks all.
There are so much knowledges to be learn.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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
![](/skins/images/7B0AB6865064EAE32B30EC9A4E94B48A/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page