Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GNU malloc_info(): get really allocated memory?

I'm trying to investigate memory use of a large multi-threaded server. According to mallinfo(), I get arena=350M and fordblks=290M, which suggests most of the space is actually wasted inside malloc(). The malloc_info() function gives a nice XML data structure that is supposed to be self-explanatory. Still, can someone explain to me

  • Is heap 0 special? Is the that main arena in which all others reside?
  • Are the <size from=.../> chunk allocated, free/available or both?
  • What is the <system> element? Memory allocated using mmap()/sbrk()?
  • What is the <aspace> element? Available memory?
  • What about <aspace type="mprotect" .../>?

Just for a start, I'd like to be able to plot total memory allocated by the application, i.e., everything allocated and not yet freed, according to what malloc() thinks.

like image 414
Jan Wielemaker Avatar asked Dec 15 '15 15:12

Jan Wielemaker


1 Answers

A large amount of virtual memory usage is not necessarily a problem. The default malloc implementation will allocate large amounts of storage per thread in order to avoid contention issues. This happens particularly on 64-bit implementations which are pretty common nowadays. You should not worry unless you experience problems with the size of resident memory or you get paging problems.

Kevin Grigorenko has written a number of blog posts which deal with memory usage in relation to WebSphere, but they are applicable to any large multi-threaded process.

like image 58
Neil Masson Avatar answered Sep 24 '22 02:09

Neil Masson