manual memory management

Walter Bright newshound2 at digitalmars.com
Wed Jan 9 10:46:45 PST 2013


On 1/9/2013 9:26 AM, Rob T wrote:
> You cannot guarantee memory safety with a GC either, depending on the definition
> of "memory safety".

GC is a necessary requirement for memory safety, but not sufficient.

> For example, you can still access deallocated memory by mistake,

If you're not playing with pointers, then this is a buggy GC.

> run out of
> memory due to accumulating persistent pointers left around by mistake,

Memory safety does not imply never running out of memory.

> or free memory that was not supposed to be freed by mistake.

Then it's a buggy GC.

> The GC implementation may
> fail due to bugs, deallocating live memory or failing to deallocate inactive
> memory.

Of course memory safety presumes a correctly implemented GC.

> The only thing a GC can do for you, is free up the programmer from the tedium of
> managing memory. It also allows constructs that otherwise would be very
> difficult or impractical to implement. The effect can be very positive, but
> there are no guarantees of memory safety.

This is incorrect - see above. A bug free GC, and not "cheating" in using it, 
guarantees memory safety. This is a big deal.



More information about the Digitalmars-d mailing list