This is the mail archive of the libc-help@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Amount of virtual Memory larger than heap peak


Hi!

My program allocates and deallocates large chunks (Megabytes) of memory many times (using new[], but this should be mapped to malloc). For example, using memusage.sh, I find out that the heap peak is about 100MB. However, the virtual memory size of my program has grown to about twice this size, as shown by top. The resident set size stays at about 100MB, as expected.

The growth of virtual memory is a problem since the program should run in an environment where virtual memory is limited using ulimit. Running the program with larger data sets increases virtual memory usage linearly, so it's not just a constant addition (the program itself has less than 10MB).

I don't use mmap, but read and write large amounts of data from disk using read(int fd, void *buf, size_t count) and the corresponding write.

Can anybody explain this behavior? How can I reduce virtual memory usage?

Johannes


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]