Linked by kragil on Wed 23rd Jan 2013 20:26 UTC
Thread beginning with comment 550276
To view parent comment, click here.
To read all comments associated with this story, please click here.
To view parent comment, click here.
To read all comments associated with this story, please click here.
RE[9]: Comment by Laurence
by moondevil on Thu 24th Jan 2013 08:18
in reply to "RE[8]: Comment by Laurence"
Is it kind of like acquiring a mutex that forbids the GC from running and thus forces it to behave exactly as you want it to ?
Well, first of all this type of code is relegated to such blocks, because manual memory management is usually used together with other tricks, so in safer languages you want to minimize its use unless it is really required.
Usually this is memory that is outside GC knowledge so it should be handled with care and not escape unsafe code.
In most languages with such features you can use compiler switches to prevent compilation of unsafe code.
Here are some links about how to do this
Modula-3
http://modula3.elegosoft.com/cm3/doc/reference/complete/html/2_7Uns...
C#
http://msdn.microsoft.com/en-us/library/system.intptr.topointer.asp...
D
http://dlang.org/memory.html
Go
A bit cumbersome, but you can do it via cgo
http://golang.org/cmd/cgo/
Oberon
Oberon's case is special, since the GC is implemented at the kernel level. So only a small piece of code, written in Assembly does manual memory management.
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.14.1857
But for the cases where the language is implemented on top of other operating systems, there are language extensions to mark pointers as not being tracked by GC.




Member since:
2010-03-08
But this is only allowed in system/unsafe code blocks.
Does it amount to disabling automatic GC and thus forcing garbage collection to run only when you want it to, like gc.disable() in Python ?
Or is it a more in-depth alteration of the language mechanics, that requires extensive programming practice changes, such as disabling garbage collection altogether and thus making all standard library code which relies on it fail ?
Edited 2013-01-24 07:50 UTC