How to free memory allocated via double[][] using dmd-2.0.12?
BCS
BCS at pathlink.com
Tue Apr 8 17:31:00 PDT 2008
Markus Dittirich wrote:
> Bill Baxter Wrote:
>
>
>>Markus, you do not show us what either read_data or process_data do.
>>It is possible that one of those is somehow holding on to references to
>>the data. This would prevent the GC from collecting the memory.
>>
>>Another problem is if you allocate the memory initially as void[] then
>>the GC will scan it for pointers, and in a big float buffer you'll get a
>>lot of false hits. To prevent that, allocate the buffer initially as
>>byte[] (or double[] --- just not void).
>>
>>Anyway, if you want a speedy fix, you'll need to distill this down into
>>something that is actually reproducible by Walter.
>>
>>--bb
>
>
> Hi Bill,
>
> You're of course absolutely correct! Below is a proof of concept code
> that still exhibits the issue I was describing. The parse code needs
> to handle row centric ascii data with a variable number of columns.
> The file "data_random.dat" contains a single row of random integers.
> After a few iterations the code runs out of memory on my machine
> and no deleting seems to help.
>
does it change things if you drop the ~= in favor of extending the
array? What about if you preallocate the array with the correct size to
begin with? (I know this might not be doable in the general case)
More information about the Digitalmars-d-learn
mailing list