Re: Memory leaks reading unfinished .exr files
"Schoenberger" <[email protected]> Mon, 26 Mar 2018 21:29:48 +0200
| Newsgroups | gmane.comp.video.openexr.devel |
|---|---|
| Message-ID | <[email protected]> |
This is a multipart message in MIME format.
--===============2211656487222470439==
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0032_01D3C549.91C30D00"
Content-Language: de
This is a multipart message in MIME format.
------=_NextPart_000_0032_01D3C549.91C30D00
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Everyone
=20
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(=85.).
initialize() allocates memory for all lines. readLineOffsets() throws =
an exception because the file is not complete.
As the exception happens in the constructor, =93new =
ScanLineInputFile()=94 returns NULL.=20
And therefore the exception catch cleanup of the function calling =93new =
ScanLineInputFile()=94 does not call the destructor of
ScanLineInputFile().
=20
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;
}
=20
=20
Holger Sch=F6nberger
technical director
The day has 24 hours, if that does not suffice, I will take the night
------=_NextPart_000_0032_01D3C549.91C30D00
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" =
xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" =
xmlns=3D"http://www.w3.org/TR/REC-html40"><head><meta =
http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1"><meta name=3DGenerator content=3D"Microsoft Word =
15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
{mso-style-priority:99;
mso-style-link:"Nur Text Zchn";
margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Courier New";
mso-fareast-language:EN-US;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.E-MailFormatvorlage18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
span.NurTextZchn
{mso-style-name:"Nur Text Zchn";
mso-style-priority:99;
mso-style-link:"Nur Text";
font-family:"Courier New";
mso-fareast-language:EN-US;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DDE link=3Dblue =
vlink=3Dpurple><div class=3DWordSection1><p class=3DMsoNormal><span =
lang=3DEN-US style=3D'mso-fareast-language:EN-US'>Hi =
Everyone<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'>I had some time to dig into the =
issue myself and would like to send you my thought on how to fix =
it.<o:p></o:p></span></p><p class=3DMsoNormal><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'><br>The main issue is that the =
constructor of e.g. ScanLineInputFile calls =A0=A0initialize(header)=A0 =
and then readLineOffsets(….).<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'>initialize() allocates memory for =
all lines. =A0readLineOffsets() throws an exception because the file is =
not complete.<o:p></o:p></span></p><p class=3DMsoNormal><span =
lang=3DEN-US style=3D'mso-fareast-language:EN-US'>As the exception =
happens in the constructor, “new ScanLineInputFile()” =
returns NULL. <br>And therefore the exception catch cleanup of the =
function calling “new ScanLineInputFile()” does not call the =
destructor of ScanLineInputFile().<o:p></o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'>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.<o:p></o:p></span></p><p =
class=3DMsoPlainText style=3D'margin-left:35.4pt'><span =
lang=3DEN-US><br>initialize(header);<o:p></o:p></span></p><p =
class=3DMsoPlainText style=3D'margin-left:35.4pt'><span =
lang=3DEN-US>[...]<br>try<o:p></o:p></span></p><p =
class=3DMsoPlainText><span lang=3DEN-US>=A0=A0=A0=A0 =
{<o:p></o:p></span></p><p class=3DMsoPlainText><span =
lang=3DEN-US>=A0=A0=A0=A0=A0=A0=A0=A0 =
readLineOffsets(*_streamData->is,<o:p></o:p></span></p><p =
class=3DMsoPlainText><span =
lang=3DEN-US>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =
_data->lineOrder,<o:p></o:p></span></p><p class=3DMsoPlainText><span =
lang=3DEN-US>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =
_data->lineOffsets,<o:p></o:p></span></p><p =
class=3DMsoPlainText><span =
lang=3DEN-US>=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0=A0 =
_data->fileIsComplete);<o:p></o:p></span></p><p =
class=3DMsoPlainText><span lang=3DEN-US>=A0=A0=A0=A0 =
}<o:p></o:p></span></p><p class=3DMsoPlainText><span =
lang=3DEN-US>=A0=A0=A0=A0 catch (IEX_NAMESPACE::BaseExc &e) =
{<o:p></o:p></span></p><p class=3DMsoPlainText><span =
lang=3DEN-US>=A0=A0=A0=A0=A0=A0=A0=A0 =
</span>ScanLineInputFile::~ScanLineInputFile();<o:p></o:p></p><p =
class=3DMsoPlainText>=A0=A0=A0=A0=A0=A0=A0=A0 throw;<o:p></o:p></p><p =
class=3DMsoPlainText>=A0=A0=A0=A0 }<o:p></o:p></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'><o:p> </o:p></span></p><p =
class=3DMsoNormal><span lang=3DEN-US =
style=3D'font-size:10.0pt;font-family:"Arial",sans-serif'>Holger =
Sch=F6nberger<br></span><span lang=3DEN-US =
style=3D'font-size:7.5pt;font-family:"Arial",sans-serif'>technical =
director<br>The day has 24 hours, if that does not suffice, I will take =
the night</span><span lang=3DEN-US =
style=3D'mso-fareast-language:EN-US'><o:p></o:p></span></p></div></body><=
/html>
------=_NextPart_000_0032_01D3C549.91C30D00--
--===============2211656487222470439==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Openexr-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/openexr-devel
--===============2211656487222470439==--