why GC not work?
FG via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Feb 8 10:43:17 PST 2015
On 2015-02-08 at 19:15, safety0ff wrote:
> On Sunday, 8 February 2015 at 16:23:44 UTC, FG wrote:
>>
>>> 2. "auto buf = new byte[](1024*1024*100);"
>>> now the gc can't free this buf.
>>> can i free it by manual?
>>
>> Yes. import core.memory; GC.free(buf.ptr); // and don't use buf afterwards
>
> That won't work, see:
> http://forum.dlang.org/thread/uankmwjejsitmlmrbufe@forum.dlang.org
Perhaps it was fixed in DMD 2.066.1, because this works for me just fine:
import core.memory;
void testGC()
{
auto b = new byte[](1024 * 1024 * 100);
GC.free(b.ptr);
}
void main()
{
foreach (i; 1..100)
testGC();
}
More information about the Digitalmars-d-learn
mailing list