octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #65669] Cell array construction is memory-inte


From: Dmitri A. Sergatskov
Subject: [Octave-bug-tracker] [bug #65669] Cell array construction is memory-intensive
Date: Mon, 6 May 2024 10:02:17 -0400 (EDT)

Follow-up Comment #31, bug #65669 (group octave):

E.g. this is on my machine (Centos Stream 9):


$ octave
<...deleted...>

octave:1> disp("---");
disp("Before anything is done:");
memory;

a = magic(1000);
b = cell(1000, 1000);
for r = 1:1000
  for c = 1:1000
    b{r, c} = a(r, c) + rand;  # Add something to eliminate any chance of lazy
copy.
  end
end

disp("---");
disp("Large matrix and large cell are allocated:");
disp(sprintf("Matrix a uses %d kiB.", whos("a").bytes / 1024));
disp(sprintf("Cell b uses %d kiB.", whos("b").bytes / 1024));
memory;

clear a
disp("---");
disp("Only cell b is allocated:");
memory;

clear all
disp("---");
disp("Right after clear all:");
memory
---
Before anything is done:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  32517436 kiB,  swap:  34603004 kiB
Octave    RAM:     97972 kiB,  virt:   5099748 kiB
Free      RAM:  23872124 kiB,  swap:  34603004 kiB
Available RAM:  28408476 kiB, total:  63011480 kiB
---
Large matrix and large cell are allocated:
Matrix a uses 7812.5 kiB.
Cell b uses 7812.5 kiB.
Octave is running on x86_64-pc-linux-gnu
System    RAM:  32517436 kiB,  swap:  34603004 kiB
Octave    RAM:    161568 kiB,  virt:   5107564 kiB
Free      RAM:  23811472 kiB,  swap:  34603004 kiB
Available RAM:  28347876 kiB, total:  62950880 kiB
---
Only cell b is allocated:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  32517436 kiB,  swap:  34603004 kiB
Octave    RAM:    153820 kiB,  virt:   5099748 kiB
Free      RAM:  23818032 kiB,  swap:  34603004 kiB
Available RAM:  28354436 kiB, total:  62957440 kiB
---
Right after clear all:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  32517436 kiB,  swap:  34603004 kiB
Octave    RAM:    153820 kiB,  virt:   5099644 kiB
Free      RAM:  23818032 kiB,  swap:  34603004 kiB
Available RAM:  28354436 kiB, total:  62957440 kiB
octave:20> 



and now with 
$ MALLOC_TRIM_THRESHOLD_=100000 octave
GNU Octave, version 9.1.91

<...deleted...>

octave:1> disp("---");
disp("Before anything is done:");
memory;

a = magic(1000);
b = cell(1000, 1000);
for r = 1:1000
  for c = 1:1000
    b{r, c} = a(r, c) + rand;  # Add something to eliminate any chance of lazy
copy.
  end
end

disp("---");
disp("Large matrix and large cell are allocated:");
disp(sprintf("Matrix a uses %d kiB.", whos("a").bytes / 1024));
disp(sprintf("Cell b uses %d kiB.", whos("b").bytes / 1024));
memory;

clear a
disp("---");
disp("Only cell b is allocated:");
memory;

clear all
disp("---");
disp("Right after clear all:");
memory
---
Before anything is done:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  32517436 kiB,  swap:  34603004 kiB
Octave    RAM:     95644 kiB,  virt:   5099508 kiB
Free      RAM:  23881836 kiB,  swap:  34603004 kiB
Available RAM:  28418272 kiB, total:  63021276 kiB
---
Large matrix and large cell are allocated:
Matrix a uses 7812.5 kiB.
Cell b uses 7812.5 kiB.
Octave is running on x86_64-pc-linux-gnu
System    RAM:  32517436 kiB,  swap:  34603004 kiB
Octave    RAM:    159472 kiB,  virt:   5115140 kiB
Free      RAM:  23819548 kiB,  swap:  34603004 kiB
Available RAM:  28356024 kiB, total:  62959028 kiB
---
Only cell b is allocated:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  32517436 kiB,  swap:  34603004 kiB
Octave    RAM:    151736 kiB,  virt:   5107324 kiB
Free      RAM:  23826296 kiB,  swap:  34603004 kiB
Available RAM:  28362772 kiB, total:  62965776 kiB
---
Right after clear all:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  32517436 kiB,  swap:  34603004 kiB
Octave    RAM:    143920 kiB,  virt:   5099404 kiB
Free      RAM:  23834620 kiB,  swap:  34603004 kiB
Available RAM:  28371096 kiB, total:  62974100 kiB
octave:20> 

-verbatim-

Dmitri.
-- 



    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?65669>

_______________________________________________
Message sent via Savannah
https://savannah.gnu.org/




reply via email to

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