Re: Preventing memory fragmentation

From: Tron Thomas (tron.thomas_at_verizon.net)
Date: 12/28/03


Date: 28 Dec 2003 13:18:31 -0800

Tom Plunket <tomas@fancy.org> wrote in message news:<fl8muvk1r1sjk9g7cb8cf6ngjpep0cofcn@4ax.com>...
> Did you try asking them for (or simply did you get) specifics
> beyond, "it'll fragment memory"?

This is an editted version of the e-mail thread between myself and the
person at the comapany who provided the feedback on my code:

----------
Hi Tron,

The c-runtime dynamic memory manager (and most other commercial memory
managers) has issues with fragmentation similar to a hard drive file
system.
Over time, the more often use call new/delete or alloc/free, there
will be
gaps and fragments in the heap. This can lead to inefficient use of
available memory, as well as cache-hit inefficiencies.

The goal of performance-critical applications is to minimize the
number of
calls to new/delete. Many use buffer managers that allocate blocks of
contiguous memory, and chain them together with list pointers when the
block
is consumed. Another approach is to use a Spare List, in which each
block of
memory is not actually freed but returned to a pool manager.

-----Original Message-----
Where can I find information on implementing and using buffer pools?

-----Original Message-----
Hi Tron,

One of his concerns was frequent calls to new and delete, which can
cause memory fragmentation over time. An example is the allocation and
destruction of a memory buffer for every network packet transmission,
vs.
employing a
buffer pool.

-----Original Message-----
I'm confused. What kinds of problems did my code have with memory
management?

-----Original Message-----
Hi Tron,

Thanks for the code samples. I had a chance to review them with our
technical director today. He did like the fact that you are willing
to tackle complicated problems. However, he had some concerns about
the efficiency of your code, particularly in its use of the memory
manager, and so I am unable to offer you a position at this time.
----------

If anyone on this group would be interested in looking at the code to
see if they agree with the comments above I would be more than willing
to make the code available to them.
 
> Is it this memory pool class you wrote that does your allocation?
> I.e. is this the memory manager that they called into question?

No, I wrote the memory manager in attempt to improve the code after
receiving the feedback.

> Your memory manager is THE naive memory manager. No offense
> intended, it's just pretty much the most basic memory manager
> that there could be.

No offense taken. I agree with you. The memory manager is naive.
After implementing it I was really wondering what I had accomplished
with it and if it was at all effective. It didn't seem to me that it
did anything more than what the default runtime memory manager for
would have been able to do. That's why I posted the code to this
newsgroup. I understood that if I requested feedback that there would
be people who would be critical of the code.



Relevant Pages

  • Re: Symbol table
    ... First, for RosAsm, i was in need of a good Memory Manager, ... KJH -- this is the guy who has refused to fix a symbol table allocation ... or multiples of 64K) and then parcel out the memory chunks using ...
    (alt.lang.asm)
  • Re: Delphi memory manager.
    ... Delphi comes in with it's memory manager, using virtual memory allocation ... Allocation is even more embarrassing since in order to use virtual allocate ... These functions internally do everything Borland's Memory Manager does... ...
    (comp.lang.pascal.delphi.misc)
  • Re: Memory Manager
    ... > practically a thing of the past with a good memory manager. ... NexusMM3, to be released shortly after NexusDB2 (in which it will be ... allocation to a new memory location and without wasting address space by ...
    (borland.public.delphi.non-technical)
  • Re: Memory Management
    ... The program is a bunch of DLLs. ... I'm still using the CRT's malloc and free to allocate memory. ... If the application makes a memory allocation request, ... I have implemented a memory manager for some SDK I'm working on (a ...
    (microsoft.public.vc.language)
  • Re: Memory fragmentation
    ... - On single CPU machine the standard memory manager is absolutely adeguate ... compared to single CPU machine. ... b - If you have a single very CPU and memory bound process a third party ...
    (borland.public.delphi.non-technical)