C Memory allocated with malloc/calloc

Ugh. "delete" I hope! Do java and javscript even have a "free"?
I suppose Java has ad-hoc "close" or "dispose" methods (albeit for resources rather than blocks of memory).

For example if you open a resource, such as a file and later on in execution, an exception occurs and stack unwinds, if you later try to open that file again, you have no guarantee that the GC has closed it yet and you will get another (this time earlier) exception if you re-enter the same code path.

So the try/catch/finally stuff and ultimately "manual" memory management is needed. Thread cleanup is also a little less elegant than the RAII approach.

Microsoft's Java obviously has the IDisposable and using cruft which is a bit useless for resources as members.
 
Ugh. "delete" I hope! Do java and javscript even have a "free"?

In a GCed language you still need to set the pointer anchoring an object to NIL for the object to be collected. That is often easier said than done and somewhat comparable to tracking memory for free()ing. This is a particular problem when you make heavy use of preallocated data spaces, which ironically you do to help the GC.
 
Back
Top