Re: Preventing memory fragmentation
From: Bob Summers (powermatic66.removethis_at_yahoo.com)
Date: 12/30/03
- Next message: Victor Bazarov: "Re: Scope-problems"
- Previous message: Howard Hinnant: "Re: iterator invalidation trouble"
- In reply to: Tron Thomas: "Re: Preventing memory fragmentation"
- Next in thread: Ron Natalie: "Re: Preventing memory fragmentation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 29 Dec 2003 18:45:32 EST
On 28 Dec 2003 13:25:19 -0800, tron.thomas@verizon.net (Tron Thomas) wrote:
>powermatic66.removethis@yahoo.com (Bob Summers) wrote in message news:<3feb7217.18345209@news.concentric.net>...
>> I've spent quite a bit of time working in integer code performance
>> in the last 10 years or so and I can truthfully say that I've never
>> worried about heap fragmentation. Heap allocation and deallocation
>> I've worried about constantly but never fragmentation. It's possible
>> that the person that interviewed you didn't know what they were
>> talking about or the two of you miscommunicated. It's also
>> possible that they were right. Without more context, I can't come
>> up with a reasonable explanation for the criticism. Was this for
>> an embedded system or numeric application? Did your interviewer
>> mean pointer chasing or other skipping around in memory instead
>> of fragmentation?
>
>Here is an editted version of the e-mail thread between me and the
>person at the company who provided the feedback:
>
>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 what you said about the code being a non-performance critical
program, it seems like they are being silly. The best engineers use
the best approach for a given problem. Heavy duty memory management
optimization has no place in a typical one-off program. In a
high-performance server, the issues are different and memory
management is something to minimize.
It sounds to me like they are just trying to find an excuse not to
hire you. Many places are like that these days.
The solutions that he proposes have the same issues with fragmentation.
Perhaps worse fragmentation in some environments and better in other.
However, most stock heap allocators behave badly under performance
pressure, especially if the program is multi-threaded. The solutions
he proposed would help reduce contention for the heap lock. IOW,
splitting the heap into memory pools distributes the lock contention
across more locks. That can be a big performance win.
Bob S
- Next message: Victor Bazarov: "Re: Scope-problems"
- Previous message: Howard Hinnant: "Re: iterator invalidation trouble"
- In reply to: Tron Thomas: "Re: Preventing memory fragmentation"
- Next in thread: Ron Natalie: "Re: Preventing memory fragmentation"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|