LWN.net Logo

C#/Java have destructors...

C#/Java have destructors...

Posted Mar 30, 2005 11:48 UTC (Wed) by phgrenet (guest, #5979)
In reply to: C#/Java have destructors... by pkolloch
Parent article: Evidence that Python is advancing into the enterprise (NewsForge)

I think one problem with Java and C# is that they only allow allocation of objects on the heap. If you can allocate your object on the stack then there is no need to control what the GC is doing because you know exactly when the object will be deallocated. C++ and Lisp give you that choice.


(Log in to post comments)

C#/Java have destructors...

Posted Mar 30, 2005 13:44 UTC (Wed) by TImaniac (guest, #28862) [Link]

In C# you can allocate a struct on the stack instead of the heap : this struct are value-types but inherit from Object.
if you need temporary stack memory, there is also a stackalloc keyword.

C#/Java have destructors...

Posted Mar 30, 2005 14:58 UTC (Wed) by cajal (subscriber, #4167) [Link]

Some JVMs can allocate objects on the stack. There is much research into this area (google for "escape analysis"). But there's no word as to when Sun's JDK will support it.

Copyright © 2012, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds