openexr-devel
[Top][All Lists]
Advanced

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

Re: [Openexr-devel] Memory leaks reading unfinished .exr files


From: Schoenberger
Subject: Re: [Openexr-devel] Memory leaks reading unfinished .exr files
Date: Mon, 26 Mar 2018 21:29:48 +0200

Hi Everyone

 

I had some time to dig into the issue myself and would like to send you my thought on how to fix it.


The main issue is that the constructor of e.g. ScanLineInputFile calls   initialize(header)  and then readLineOffsets(….).

initialize() allocates memory for all lines.  readLineOffsets() throws an exception because the file is not complete.

As the exception happens in the constructor, “new ScanLineInputFile()” returns NULL.
And therefore the exception catch cleanup of the function calling “new ScanLineInputFile()” does not call the destructor of ScanLineInputFile().

 

If I catch the exception in the constructor and call the destructor, I was able to reduce the memory leak from 600KB to 3KB so far.


initialize(header);

[...]
try

     {

         readLineOffsets(*_streamData->is,

             _data->lineOrder,

             _data->lineOffsets,

             _data->fileIsComplete);

     }

     catch (IEX_NAMESPACE::BaseExc &e) {

         ScanLineInputFile::~ScanLineInputFile();

         throw;

     }

 

 

Holger Schönberger
technical director
The day has 24 hours, if that does not suffice, I will take the night


reply via email to

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