11.10.05
About memory
We met some problems for our 32-bit applications with memory in HP-UX recently. One is the single process exceeded 1 G limit, the other is memory of CORBA server is too big while running for long time.
For the first problem, we can migrate application to 64-bit, or link using “-N”. It can change the executable file’s format to EXEC_MAGIC, which can support nearly 1.9GB.
And the second problem, while most unix dont return the free memory to the operating system, the application should be optimized. (“mapmalloc can return dynamic allocated memory to the OS, but the price is that memory allocation takes about five times longer”, said in “Modern Memory Management“) Something may be caused by dynamic allocation of STL, like vector. It’s better to use reserve for vector.
Some suggestions are also given in the article:
1. It is always wise to free objects you do not need, especially large ones as soon as possible, to minimize this footprint.
2. To avoid problems with memory fragmentation, try to avoid making many small memory allocations and instead replace them with one or two large allocations where possible.