[Exceptional C++ Style] Item 20: Containers in Memory, Part 1: Levels of Memory Management.

Paul Grenyer paul at paulgrenyer.co.uk
Mon Jan 10 12:43:26 EST 2005


Hi

My summary is not on the project site: 
http://www.paulgrenyer.dyndns.org/cppstyle/items.php#item20

Does anyone else think that Herb doesn't really answer the JG question: 
"What are memory managers (also known as memory allocators) and what is 
their basic function?

Regards
Paul

Paul Grenyer
email: paul at paulgrenyer.co.uk
web: http://www.paulgrenyer.co.uk
Elephant: http://www.paulgrenyer.dyndns.org/elephant/

Darrell "Dimebag" Abbott will be sorely missed.


----- Original Message ----- 
From: "Paul Grenyer" <paul at paulgrenyer.co.uk>
To: <effective-cpp at accu.org>
Sent: Monday, January 10, 2005 5:30 PM
Subject: [Exceptional C++ Style] Item 20: Containers in Memory,Part 1: 
Levels of Memory Management.


> Memory Managers and Their Strategies: A brief summary
> -----------------------------------------------------
>
> Memory Managers, also known as memory allocates, are used to allocate 
> memory
> for containers. There are a number of different memory management 
> strategies
> available, two popular ones are:
>
> - General-purpose allocation can provide any size of memory block that a
> caller might request (the request size, or block size). General-purpose
> allocation is very flexible but has several drawbacks, two of which are:
>
> 1) Performance, because it has more work to do
> 2) Fragmentation , because as blocks are allocated and freed we can end up
> with lots of little non-contiguous areas of unallocated memory
>
> - Fixed-size allocation always returns a block of the same fixed size. 
> This
> is obviously less flexible than general purpose allocation, but it can be
> done much faster and doesn't result in the same kind of fragmentation.
>
>
> Plotting Strategy
> -----------------
>
> The operating system kernel provides the most basic memory allocation
> services. Different operating systems have different strategies and also
> take into account the particular hardware they are running on.
>
> The compiler's default runtime library builds its allocation services, 
> such
> as C++ operator new and C's malloc, upon the native allocation services.
>
> The standard containers and allocators in turn use the compiler's services
> and possibly further override them to implement their own strategies and
> optimizations.
>
> Finally, user-defined containers and/or user-defined allocators can 
> further
> reuse any lower-level of services and do pretty much whatever they please.
>
> Guideline: Know who does what: Understand the actual (and 
> system-dependant)
> allocation strategies and responsibilities of your platform and standard
> library.
>
>
>
[ *** too many quoted lines.  automatically truncated *** ]





More information about the Effective-cpp mailing list