Deallocate array?

Ali Çehreli acehreli at yahoo.com
Tue May 7 16:58:53 PDT 2013


On 05/07/2013 04:42 PM, Matic Kukovec wrote:

 > On Tuesday, 7 May 2013 at 23:31:41 UTC, Ali Çehreli wrote:
 >> On 05/07/2013 04:18 PM, Matic Kukovec wrote:
 >>
 >> > On Tuesday, 7 May 2013 at 23:14:20 UTC, Ali Çehreli wrote:
 >> >> GC.minimize() may work.
 >>
 >> > Tried it, no changes.
 >>
 >> Works for your test program under Linux but as the documentation says,
 >> it is not guaranteed to have any effect at all.
 >>
 >> Ali
 >
 > I found this problem with a program that reads a large xml file (250000+
 > lines), then stores the lines in a string[], does a comparison with
 > another array and finally clears the original array.

You don't need to clear the original array but it should be harmless.

 > On the second or third file I always get an OutOfMemoryError, when the
 > Task Manager shows about 1.3GB memory usage.
 >
 > Is this a Windows specific thing or am I doing something wrong?

Is this a 32-bit platform? If so, the reason may be the conservative GC 
that dmd uses. What happens is, unrelated 32-bit values in other parts 
of the program may look like pointers into the allocated space and the 
GC thinks that they are still in use.

Ali



More information about the Digitalmars-d-learn mailing list