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: Henry Shu
Subject: [Octave-bug-tracker] [bug #65669] Cell array construction is memory-intensive
Date: Sat, 4 May 2024 09:12:50 -0400 (EDT)

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

After reading up on [https://stackoverflow.com/a/10945602/3969835 this], I
wrote a quick oct-file


#include <octave/oct.h>
#include <malloc.h>

DEFUN_DLD (malloc_trim_oct, args, , "Just a quick test") {
  int pad = args(0).scalar_value();
  int res = malloc_trim(pad);
  octave_value_list argout(1);
  argout(0) = res;
  return argout;
}


I compiled it as


mkoctfile malloc_trim_oct.cpp -o malloc_trim_oct.oct


Running the script from [comment #17 comment #17] again to get the
memory-hogging behavior just like before:


---
Before anything is done:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  65894144 kiB,  swap:   8387580 kiB
Octave    RAM:    120552 kiB,  virt:  21963236 kiB
Free      RAM:  60328360 kiB,  swap:   8387580 kiB
Available RAM:  64392608 kiB, total:  72780188 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:  65894144 kiB,  swap:   8387580 kiB
Octave    RAM:    183160 kiB,  virt:  22036588 kiB
Free      RAM:  60266716 kiB,  swap:   8387580 kiB
Available RAM:  64330992 kiB, total:  72718572 kiB
---
Only cell b is allocated:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  65894144 kiB,  swap:   8387580 kiB
Octave    RAM:    175396 kiB,  virt:  22028772 kiB
Free      RAM:  60270204 kiB,  swap:   8387580 kiB
Available RAM:  64334480 kiB, total:  72722060 kiB
---
Right after clear all:
Octave is running on x86_64-pc-linux-gnu
System    RAM:  65894144 kiB,  swap:   8387580 kiB
Octave    RAM:    175140 kiB,  virt:  22028236 kiB
Free      RAM:  60270204 kiB,  swap:   8387580 kiB
Available RAM:  64334480 kiB, total:  72722060 kiB


And it seems on my system I can now release some memory back to OS by doing:


octave:2> res = malloc_trim_oct(0); disp(res); memory;
1
Octave is running on x86_64-pc-linux-gnu
System    RAM:  65894144 kiB,  swap:   8387580 kiB
Octave    RAM:    112108 kiB,  virt:  22028156 kiB
Free      RAM:  60336028 kiB,  swap:   8387580 kiB
Available RAM:  64400560 kiB, total:  72788140 kiB




    _______________________________________________________

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]