[Top][All Lists]

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

Is there memory leak in this approach?

From: babelproofreader
Subject: Is there memory leak in this approach?
Date: Sat, 24 Sep 2011 05:45:25 -0700 (PDT)

I have written many .oct functions which require numerous arrays/vectors to
hold internal calculations, but which output perhaps just a few of these
arrays/vectors as return values. A simplistic example is:

DEFUN_DLD (complex_function, args, , "Help String")
  octave_value retval;
  ColumnVector input = args(0).column_vector_value ();
  ColumnVector internal_vector_1 = args(0).column_vector_value ();
  ColumnVector internal_vector_2 = args(0).column_vector_value ();
  ColumnVector internal_vector_3 = args(0).column_vector_value ();
  ColumnVector output = args(0).column_vector_value ();

   for (octave_idx_type ii (0); ii < input.length(); ii++)
        main code loops and writes to internal_vector_1, internal_vector_2
        & internal_vector_3 during course of calculations, and final result
        written to output      

  retval = output;
  return retval;

My concern is: What happens to the internal_vectors? Do I need to clean them
up in some way or is the memory they occupy automatically released once the
function exits?

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]