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

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

[Octave-bug-tracker] [bug #62459] Severe memory leak when functions are


From: Arun Giridhar
Subject: [Octave-bug-tracker] [bug #62459] Severe memory leak when functions are nested
Date: Mon, 16 May 2022 08:42:48 -0400 (EDT)

Update of bug #62459 (project octave):

              Item Group:                    None => Segfault, Bus Error, etc.
                  Status:                    None => Confirmed              
                 Release:                   7.1.0 => dev                    
        Operating System:       Microsoft Windows => Any                    

    _______________________________________________________

Follow-up Comment #1:

Can reproduce on on Linux with Octave 8. Changing OS to Any and Release to
dev. Listing it as a Segfault since OP got a system freeze from the unchecked
leak.

To make it less drastic for testing, here is a milder version that causes
memory usage to climb linearly with each execution of test_memleak:

function test_memleak
  for i = 1:10
    f(rand(1000));
  end
endfunction

function retval = f(p)
  R = p * rand(1);
  f_blah = @() 1./R;
  
  function ret = g()
    ret = f_blah();
  endfunction

  retval = g();
endfunction


Calling "clear all" does not release the memory.

There is NO leak for this version of f(p):

function retval = f(p)
  R = p * rand(1);
  f_blah = @() 1./R;
  retval = f_blah();
endfunction

and this is safe too as expected:

function retval = f(p)
  R = p * rand(1);
  retval = 1./R;
endfunction


If Matlab allows nested functions, could someone please check what it does?


    _______________________________________________________

Reply to this item at:

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

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




reply via email to

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