How to free memory allocated via double[][] using dmd-2.0.12?
Markus Dittrich
markusle at gmail.com
Tue Apr 8 08:21:37 PDT 2008
Regan Heath Wrote:
> Did you try just setting the array reference to null. This should make
> the contents of the array unreachable and therefore it should be
> collected when you next allocate (and run short on memory).
>
> i.e.
>
> int main()
> {
> double[][] myLargeDataset;
> while (some condition)
> {
> myLargeDataset = read_data();
> process_data(myLargeDataset);
> myLargeDataset = null;
> }
>
> return 0;
> }
>
> Regan
Thanks for the hint. I just tried this again just to make sure and also
tried plopping an std.gc.fullCollect() right after to force the GC to
collect. In both cases I can watch memory consumption grow continuously
with the system running out of memory eventually. Maybe its a GC bug?
Markus
More information about the Digitalmars-d-learn
mailing list