Using GCC, you can force the STL to use malloc and to free memory as soon as possible by globally disabling memory caching. Beware! Doing so will probably slow down your program, sometimes drastically.
-
With GCC 2.91, 2.95, 3.0 and 3.1, compile all source using the STL with
-D__USE_MALLOC
. Beware! This was removed from GCC starting with version 3.3. -
With GCC 3.2.2 and later, you should export the environment variable
GLIBCPP_FORCE_NEW
before running your program. -
With GCC 3.4 and later, that variable has changed name to
GLIBCXX_FORCE_NEW
.