octave-maintainers
[Top][All Lists]
Advanced

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

possible memory wasting in array handling


From: Olaf Till
Subject: possible memory wasting in array handling
Date: Thu, 19 Jan 2017 15:16:44 +0100
User-agent: Mutt/1.5.23 (2014-03-12)

On the help list, a problem came up where a probable memory exhaustion
occured only if some large array operations, with indexing, took place
before (they took place within a called function). This reminded me of
the following possible problem with the current array handling.

The Array class maintains a pointer to (and a length of) a 'slice' of
data in ArrayRep. If a smaller array B is created by continuous
indexing of a larger one A:

A = rand (1, 1000000);

B = A(1:1000);

B references a 'slice' in the data of A, without allocating own memory
for the data. But if A is cleared (or destructed on return from a
function), all of its memory remains allocated, as long as B exists
(even though B needs only a small part of this memory). (Even on
writing into B, Array::make_unique() does not help with this if B is
the only reference to the data.)

Is this behavior considered problematic, or even a bug? It possibly
has caused the said problem on the help list. One possibility would be
to just remove this 'slice' optimization. A more difficult way would
involve to maintain, in ArrayRep, not only a refcount, but also a
notion of the greatest slice referenced by any Array.

Olaf

-- 
public key id EAFE0591, e.g. on x-hkp://pool.sks-keyservers.net

Attachment: signature.asc
Description: Digital signature


reply via email to

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