Limiting virtual memory allocation/reservation

8 views (last 30 days)
Matlab 2013a CentOS 6.1 64-bit
Matlab (with GUI) allocates/reserves (not sure which is proper for VIRT) almost 4.2G of virtual memory when it launces, even though it's only using a few hundred M, as shown by top:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
15396 mgstauff 20 0 4131m 355m 75m S 1.0 0.6 0:14.97 MATLAB
The problem for me is that I'm running a Rocks cluster and want to limit the users by default to 3.9G of memory/virtual-memory usage/allocation. Rocks sets limits using ulimit.
1) Can I setup my matlab installation to by default allocate/reserve less virtual memory for all users? If not, is there a manual way?
2) I'm assuming this allocation is not a fixed limit, but rather an initial allocation to have a contiguous block of memory ready for use? That is, if users want more memory while running matlab, this will expand.
Thanks!
-M
  2 Comments
Michael Stauffer
Michael Stauffer on 15 May 2014
Could someone from Mathworks comment on this, even if it's impossible to change? Would be good to know either way.
Michael Stauffer
Michael Stauffer on 23 Jul 2014
I've got an answer/workaround from Matlab support folks - thanks! With setting the env var MALLOC_ARENA_MAX=4, VIRT usage is done to 1.3GB instead of ~4GB. Nice.
"I have one other thing I’d like you to try. One of our developers mentioned that there was a change made to the memory manager in Red Hat 6. Additional virtual memory is allocated in 64 MB blocks (they call them “arenas”) in order to eliminate false sharing among multiple cores. An environment variable is available to limit the number of arenas, MALLOC_ARENA_MAX . Could you set the value of this environment variable to 1 and see if that makes a difference? I tested it on a Red Hat 6 machine in our quality lab. On that machine, when I started MATLAB with –nojvm, it used 806 MB virtual memory. I then set the environment variable to 1, and it used 673 MB. The difference is close to two 64 MB blocks. If this reduces the memory, you could try various values. With a value of 1, false sharing may occur under certain circumstances (the same behavior that always occurred in Red Hat 5). The larger the number, the less likely false sharing. I looked online and found a suggested value of 4."
A couple links:
Hadoop says set to 4: https://issues.apache.org/jira/browse/HADOOP-7154
IBM: https://www.ibm.com/developerworks/community/blogs/kevgrig/entry/linux_glibc_2_10_rhel_6_malloc_may_show_excessive_virtual_memory_usage?lang=en

Sign in to comment.

Answers (0)

Categories

Find more on Introduction to Installation and Licensing in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!