I have found that the infiniserv MPI that comes with our IB software distribution tracks the same behaviour as gcc (releaseing memory on realloc). I have also found that building openmpi with --without-memory-manager makes openmpi track the same behaviour as glibc. I'm guessing that there is a bug in the pinned pages caching code?
On 8/21/07, Josh Aune <lu...@lnxi.com> wrote: > The realloc included with openmpi 1.2.3 is not releasing memory to the > OS and is causing apps to go into swap. Attached is a little test > program that shows calls to realloc not releasing the memory when > compiled using mpicc, but when compiled directly with gcc (or icc) > calling realloc() frees any memory no longer needed. > > Is this a bug? > > If not, how can I force openmpi to free the memory that the allocator > is sitting on? > > Thanks, > Josh > > Sample output. Note the delta between 'total' and 'malloc held' when > compiled with mpicc and how the gcc compiled versions track perfectly. > > $ mpicc -o realloc_test realloc_test.c > $ ./realloc_test > ... > malloc/realloc/free test > malloc() 50 MB, total 50 MB, malloc held 50 MB > realloc() 1 MB, total 1 MB, malloc held 50 MB > malloc() 50 MB, total 51 MB, malloc held 100 MB > realloc() 1 MB, total 2 MB, malloc held 100 MB > malloc() 50 MB, total 52 MB, malloc held 150 MB > realloc() 1 MB, total 3 MB, malloc held 150 MB > malloc() 50 MB, total 53 MB, malloc held 200 MB > realloc() 1 MB, total 4 MB, malloc held 200 MB > malloc() 50 MB, total 54 MB, malloc held 250 MB > realloc() 1 MB, total 5 MB, malloc held 250 MB > free() 1 MB, total 4 MB, malloc held 200 MB > free() 1 MB, total 3 MB, malloc held 150 MB > free() 1 MB, total 2 MB, malloc held 100 MB > free() 1 MB, total 1 MB, malloc held 50 MB > free() 1 MB, total 0 MB, malloc held 0 MB > ... > > $ gcc -o realloc_test realloc_test.c > $ ./realloc_test > ... > malloc/realloc/free test > malloc() 50 MB, total 50 MB, malloc held 50 MB > realloc() 1 MB, total 1 MB, malloc held 1 MB > malloc() 50 MB, total 51 MB, malloc held 51 MB > realloc() 1 MB, total 2 MB, malloc held 2 MB > malloc() 50 MB, total 52 MB, malloc held 52 MB > realloc() 1 MB, total 3 MB, malloc held 3 MB > malloc() 50 MB, total 53 MB, malloc held 53 MB > realloc() 1 MB, total 4 MB, malloc held 4 MB > malloc() 50 MB, total 54 MB, malloc held 54 MB > realloc() 1 MB, total 5 MB, malloc held 5 MB > free() 1 MB, total 4 MB, malloc held 4 MB > free() 1 MB, total 3 MB, malloc held 3 MB > free() 1 MB, total 2 MB, malloc held 2 MB > free() 1 MB, total 1 MB, malloc held 1 MB > free() 1 MB, total 0 MB, malloc held 0 MB > ... > >