[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

private scope data destruction, or GC; How it works?

From: hale812
Subject: private scope data destruction, or GC; How it works?
Date: Thu, 19 Jan 2017 00:35:33 -0800 (PST)

In certain scenarios when using fast vector operations instead of manual "for
i=1:length(Array)", I am getting 
"out of memory or dimension too large for Octave's index type"

The problem is that I am specifically reducing size of the array in some
optimizing function.

When I build this function using "for i" statement, it works.

Then, I do almost the same using pure vector operations, in the following
    % data format [u1, u2, u3...; v1, v2, v3...]
    [inod, ipin]=meshgrid([1:size(nodes,2)],[1:size(pin,2)]);
    indices=[inod(:)'; ipin(:)'];
    distances=nodes(:,indices(1,:))-pin(:,indices(2,:)); %paths from the pin
to nodes in the domain
    distances=sqrt(distances(1,:).^2+distances(2,:).^2); %because norm does
not work on 2D data in set
    proxim_is=indices(:,find(distances<=thresh)); %indices of closest
[node;point] pairs
    proxim_ds=distances(:,find(distances<=thresh)); %distances of the pairs
and so on... It allows me to find closest node not just in current
iteration, but unique optimal nodes for the the whole set of pins, avoiding
one iteration overlapping with/or pushing out the next iteration.

BUT, after finishing this search function (with the same amount of solution
data), the main program fails with: "out of memory or dimension too large
for Octave's index type"

For me it looks like "stack overflow", because I have 16Gb of RAM, and only
2Gb used.

So, the question, does Octave free (destruct) all the function local scope
data uppon finishing the function with "endfunction" or "return"?
Or the allocated memory is not freed and I need to manually "A=[]; clear A;"
for every array INSIDE the function before finishing the job?

Is it the same for functions in the script and for functions loaded from

View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]