Re: Thoughts on memory freeing




"santosh" <santosh.k83@xxxxxxxxx> wrote in message
news:g6nd3o$omb$1@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
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.

Oh, I was thinking of just calling 'free' in it's own thread as the main
implementation idea. I take it the system's free implementation probably
already does 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.

Thanks. Time to see which my library has. I was looking more for the
theoretical than the language specific, but I guess language specific would
have insight into implementations and how they handled memory management. I
never considered that 'free' might already take this approach.

Thanks for the reading list.


.



Relevant Pages

  • Re: How come Ada isnt more popular?
    ... I think the absence of manual memory management code actually furthers ... the rest of the language in such a way that GNAT didn't get it right ... fcuntional langauges you can do more against ressource leaks, ...
    (comp.lang.ada)
  • Re: Executable Memory in a Driver
    ... >> criminal to expose users to the added bluescreen and security risk. ... In a language that can't access outside an array, ... that doesn't need to move memory. ... > desired in the compiler. ...
    (microsoft.public.development.device.drivers)
  • Re: How come Ada isnt more popular?
    ... bother with *manual* memory management neither. ... Today manual memory management is a low-level thingy that you don't have to care about, unless you *really* want to. ... The problem is that few programs rely on only memory and in a typical case there are lots of resources that are not memory oriented and they have to be managed, ... When GC is a shiny center of the language, those other kinds of resources suffer from not having appropriate support. ...
    (comp.lang.ada)
  • Re: [opensuse] c question - how to tell how much memory you program/data structure uses?
    ... Is there a way to determine how much memory I'm using besides ... If you are trying to familiarise yourself with c, strings and lists then ... but the Java and Perl ... choosing the right type of language is a useful start.... ...
    (SuSE)
  • Re: Whats the best language to learn...
    ... on processors designed to run Lisp and Lisp OSes. ... byte-addressed memory, has native support for variable-sized value types, ... popular OO language, rather a language about like that of Delphi would have ... lisp, java, ruby, etc. ...
    (comp.programming)