Access of a nested structure memory leak in mex function

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Access of a nested structure memory leak in mex function

vrozos
The access of a nested structure passed to a mex function seems to
create memory leak.

Example code:

  mxArray* pmx1=NULL;
  mxArray* pmxid=NULL;
  pmx1= mxGetField(prhs[0], 0, "InsDmd");
  pmxid= mxGetField(pmx1, 0, "id");        // <-- memory leak stops when
commenting this out


This problem has been witnessed in Octave 5.1.0/win64 and Octave
4.2.2/Linux (I believe exists in every platform and recent Octave
version). The same code does not create leak when compiled in MATLAB.

Apparently, the indicated line code above does not create directly the
leak, but somehow confuses the memory management. The leak is noticeable
only after numerous calls of the mex function (7.6 MB/100000 calls).

Evangelos Rozos





Reply | Threaded
Open this post in threaded view
|

Re: Access of a nested structure memory leak in mex function

Rik-4
On 07/04/2019 09:01 AM, [hidden email] wrote:
Subject:
Access of a nested structure memory leak in mex function
From:
Evangelos Rozos [hidden email]
Date:
07/04/2019 03:59 AM
To:
[hidden email]
List-Post:
[hidden email]
Content-Transfer-Encoding:
8bit
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
text/plain; charset=utf-8; format=flowed
Message:
1

The access of a nested structure passed to a mex function seems to create memory leak.

Example code:

 mxArray* pmx1=NULL;
 mxArray* pmxid=NULL;
 pmx1= mxGetField(prhs[0], 0, "InsDmd");
 pmxid= mxGetField(pmx1, 0, "id");        // <-- memory leak stops when commenting this out


This problem has been witnessed in Octave 5.1.0/win64 and Octave 4.2.2/Linux (I believe exists in every platform and recent Octave version). The same code does not create leak when compiled in MATLAB.

Apparently, the indicated line code above does not create directly the leak, but somehow confuses the memory management. The leak is noticeable only after numerous calls of the mex function (7.6 MB/100000 calls).

Evangelos Rozos

Could you file this as a bug report at bugs.octave.org?  It is liable to get lost on the mailing list.

When you do file a report, please include the Octave m-file code that is associated with the mex C code so that the issue can be reproduced.

Thanks,
Rik

Reply | Threaded
Open this post in threaded view
|

Re: Access of a nested structure memory leak in mex function

vrozos
Yes, I will do that.

On Mon, 8 Jul 2019 at 18:35, Rik <[hidden email]> wrote:
On 07/04/2019 09:01 AM, [hidden email] wrote:
Subject:
Access of a nested structure memory leak in mex function
From:
Evangelos Rozos [hidden email]
Date:
07/04/2019 03:59 AM
To:
[hidden email]
List-Post:
[hidden email]
Content-Transfer-Encoding:
8bit
Precedence:
list
MIME-Version:
1.0
Message-ID:
[hidden email]
Content-Type:
text/plain; charset=utf-8; format=flowed
Message:
1

The access of a nested structure passed to a mex function seems to create memory leak.

Example code:

 mxArray* pmx1=NULL;
 mxArray* pmxid=NULL;
 pmx1= mxGetField(prhs[0], 0, "InsDmd");
 pmxid= mxGetField(pmx1, 0, "id");        // <-- memory leak stops when commenting this out


This problem has been witnessed in Octave 5.1.0/win64 and Octave 4.2.2/Linux (I believe exists in every platform and recent Octave version). The same code does not create leak when compiled in MATLAB.

Apparently, the indicated line code above does not create directly the leak, but somehow confuses the memory management. The leak is noticeable only after numerous calls of the mex function (7.6 MB/100000 calls).

Evangelos Rozos

Could you file this as a bug report at bugs.octave.org?  It is liable to get lost on the mailing list.

When you do file a report, please include the Octave m-file code that is associated with the mex C code so that the issue can be reproduced.

Thanks,
Rik