Re: Thoughts on memory freeing
- From: santosh <santosh.k83@xxxxxxxxx>
- Date: Tue, 29 Jul 2008 21:00:49 +0530
S James S Stapleton wrote:
In languages, you end up having 'garbage collecting' methods for
freeing memory, and the other kind (I don't know the term off the top
of my head, but it's seen in C/C++ and done by directly calling the
memory deallocation function).
One term you can use is manual memory management, as opposed to Garbage
Collection whose whole purpose is to automate the task of deallocation.
There's arguments as to which is better for a program, and a lot of
what I've seen points to the GC methods.
If your language supports GC and you can accept some of it's
shortcomings, then GC certainly frees you from what would otherwise be
tedious accounting and not directly related to the problem that the
program tries to solve.
If you are using a language
where GC is nontrivial, would it be advantage to have a memory
deallocation thread? By that I mean, rather than directly deallocate
(i.e. a free call), call something which will put the memory free'ing
on another thread (either by placing it on a to-be-deleted queue -
which would have delays due to locks/mutexes, or by running each
deallocation in it's own thread - which would have the thread creation
overhead).
You would be reimplementing a lot of the functionality of your
language's "free" routine by doing this, unless of course your language
is primitive enough to not provide them in the first place.
For some applications which have a complex pattern of allocation and
deallocation it might indeed benefit from a customised memory manager.
Such examples are quite common in many large programs. But I would
stick to the functionality provided by the language unless such need is
really felt, since a good memory allocator is no trivial task,
particularly with the advent of multi-threading.
Does anyone have any thoughts (or better yet, suggestions for good
reading, preferably of the dead-tree kind, that I could pick up at the
library) on this?
<http://search.barnesandnoble.com/Memory-as-a-Programming-Concept-in-C-and-C/
Frantisek-Franek/e/9780521520430/?itm=3>
<http://search.barnesandnoble.com/Garbage-Collection/Richard-Jones/e/
9780471941484/?itm=2>
<http://www.memorymanagement.org/>
<http://portal.acm.org/citation.cfm?id=582419.582421>
<http://g.oswego.edu/dl/html/malloc.html>
<http://www.hoard.org/>
<http://www.fourmilab.ch/bget/>
and
Section 2.5 in Knuth's Fundamental Algorithms.
Also various language specific books (for example The Standard C Library
by PJ Plauger and C Unleashed by Heathfield, Kirby et al for C) devote
sections to consider memory allocation for their languages.
.
- Follow-Ups:
- Re: Thoughts on memory freeing
- From: S James S Stapleton
- Re: Thoughts on memory freeing
- References:
- Thoughts on memory freeing
- From: S James S Stapleton
- Thoughts on memory freeing
- Prev by Date: Thoughts on memory freeing
- Next by Date: Re: Thoughts on memory freeing
- Previous by thread: Thoughts on memory freeing
- Next by thread: Re: Thoughts on memory freeing
- Index(es):
Relevant Pages
|