how to debug memory errors
bachmeier via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Nov 8 03:26:55 PST 2016
On Monday, 7 November 2016 at 02:22:35 UTC, Steven Schveighoffer
wrote:
> Imagine a resource wrapper like so:
>
> class Foo
> {
> int *mem;
> this() { mem = cast(int *)malloc(int.sizeof); }
> ~this() { .free(mem); }
> }
>
> Now, you have a problem if you do something like this:
>
> class Bar
> {
> Foo foo;
> ~this() { delete foo; }
> }
>
Is there a valid use case for something like this? Why would you
want to do anything inside ~this with GC memory?
More information about the Digitalmars-d-learn
mailing list