Re: Avoiding heap fragmentation in C++ program on solaris



On Mar 19, 1:43 am, "Richard B. Gilbert" <rgilber...@xxxxxxxxxxx>
wrote:
Rahul wrote:
Hi,

My application was showing high heap fragmentation on windows which I
solved using Low Fragmented Heap (LFH) option for the CRunTime heap.
I was wondering If there exists a similar feature on Solaris (Sun CC)
compiler also. Is there any way to reduce heap fragmentation in C++
programs.

Thanks

It might help to look at your program!  malloc() and free() made a lot
of sense when running in early hardware with limited memory and/or
address space.  In today's virtual memory systems with Gigabytes of real
RAM it's much less necessary.

There are still situations where malloc() and free() are the right tools
for the job; I'm just suggesting that you look and see if what the
program is doing makes sense!

Hi,

There are multiple threads in the program (> 14) each does a small
amount of processing so they keep allocating and freeing small buffers
of memory (1 KB to 100 MB in size). After runing the app for 1-2 hour
the virtual memory gets fragmented (As observed on windows, But I am
not sure how to verify this on Solaris) and malloc starts failing
(for large sizes e.g. 80 MB).
The allocation size is purely random and can not be predicted in
advance. We thought of providing out own memory management using
bucket strategy (or buddy system) but that might cause high internal
fragmentation.


.



Relevant Pages

  • Re: How to release heap memory that is marked as free
    ... fragmentation and you don't control the code then you can do little ... You could use a memory mapped file to ... I removed the heap walker calls and put in a heapstat function ... using, but I don't have much control over ZipArchive, and I have ...
    (microsoft.public.vc.mfc)
  • Re: HeapAlloc heap fragmentation.
    ... > The problem is not one of fragmentation but one of not haveing any virtual ... > in the standard heap. ... > allocates 1-2gb of small objects, frees ALL of them and tries to allocate ... > large objects will fail due to out of memory. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: Preventing memory fragmentation
    ... >> worried about heap fragmentation. ... >> I've worried about constantly but never fragmentation. ... >The c-runtime dynamic memory manager (and most other commercial memory ... >memory is not actually freed but returned to a pool manager. ...
    (comp.lang.cpp)
  • Re: HeapAlloc heap fragmentation.
    ... memory" or search comp.softsys.matlab for the scale of the problem. ... The problem is not one of fragmentation but one of not haveing any virtual ... Because address space only goes into the heap any applictaion that allocates ... frees ALL of them and tries to allocate large ...
    (microsoft.public.win32.programmer.kernel)
  • Re: standard c++ containers, memory and aix
    ... Solaris and AIX: ... Control heap usage with soft limits. ... Has a memory "segment" architecture. ...
    (comp.unix.aix)