LINUX.IE, website of the Irish Linux Users' Group
Tux rules!

   
Home
New Users
Articles
Download
Projects
Community
Vendors

  Print Version
Email to...
 
Archives:


planetILUG

Recent News

News Archive


Join the
ILUG
on FaceBook


Join the
ILUG
on LinkedIn


Join the
ILUG SETI
Group



















 
 :: Mailing Lists

[ILUG] introduction to programming

[ILUG] introduction to programming

Paul Jakma paul at clubi.ie
Wed May 25 17:41:27 IST 2005


On Wed, 25 May 2005, Braun Brelin wrote:

> 1.  Garbage collection.  No more malloc()/free() issues.

You can do this in C. Refcounts + last decrementer frees is quite 
trivial.

You can do more advanced garbage collection if you want, even a 
psuedo-background-GC, if you registered memory references. Something 
like:

some_type *foo, *bar;

bar = memnew (sizeof foo);
foo = memref (&foo, bar); /* &foo holds reference to bar */

/* you could now 'memfree' bar.. and not have it free'd until
  * &foo is memunref'd or even whenever &foo no longer holds the value
  * of bar - in which case memunref would not be needed.
  */

Fully automatic scanning of heap and keeping track of references in 
stack (and hence not having to 'register' references) would be quite 
difficult in C I suspect (and platform specific)

memnew, memref and memunref are left as an exercise for the reader. 
Your system may already provide libraries which implement such things 
(eg glib has 'caches' i think).

If you're using malloc/free bare, you're doing something wrong :). 
I'd /almost/ argue that general code that fails to compile with 
malloc/free defined to something nonsensical is broken.

regards,
-- 
Paul Jakma	paul at clubi.ie	paul at jakma.org	Key ID: 64A2FF6A
Fortune:
Superior ability breeds superior ambition.
 		-- Spock, "Space Seed", stardate 3141.9



More information about the ILUG mailing list
Read this without the formatting.
                                                                                                    

 

Hosted by HEAnet


Maintained by the ILUG website team. The aim of Linux.ie is to support and help commercial and private users of Linux in Ireland. You can display ILUG news in your own webpages, read backend information to find out how. Networking services kindly provided by HEAnet, server kindly donated by Dell. Linux is a trademark of Linus Torvalds, used with permission. No penguins were harmed in the production or maintenance of this highly praised website. Looking for the Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!
RSS Version
Powered by Dell