Apache OpenOffice (AOO) Bugzilla – Issue 120028
[From Symphony] There is a memory leak in function SwWW8ImplReader::MatchSdrBoxIntoFlyBoxItem
Last modified: 2013-02-16 09:18:32 UTC
Steps to reproduce the defect: 1) Launch Aoo3.4 2) New a odt file, insert a line in it 3) Save it as MS word 97 file, close it 4) Reopen the doc file Defect : There is a memory leak in function SwWW8ImplReader::MatchSdrBoxIntoFlyBoxItem
Code snippet: for(sal_uInt16 nLine = 0; nLine < 4; ++nLine) rBox.SetLine(new SvxBorderLine( aLine ), nLine); A temporary object typed SvxBorderLine will be created to pass to function "void SvxBoxItem::SetLine( const SvxBorderLine* pNew, sal_uInt16 nLine )", in which the first argument will be used to construct a new object. But this temporary object will not be released.
Created attachment 78388 [details] for file "main/sw/source/filter/ww8/ww8graf.cxx"
Indeed, SvxBoxItem::SetLine() clones the provided SvxBorderLine object and that leaks. Thanks for finding and solving it! Applied as revision 1351616. As a next step one could investigate whether SvxBoxItem::SetLine() should be changed to use the provided SvxBorderLine directly instead of cloning it. This would save two heap operations per line.
BTW: The patch has almost no risk and if it saves a significant amount of memory then this issue should become a AOO 3.4.1 candidate. ChaoHuang: can you give a rough estimate how much memory will be saved in a common scenario?
(In reply to comment #3) > Indeed, SvxBoxItem::SetLine() clones the provided SvxBorderLine object and > that leaks. Thanks for finding and solving it! > Applied as revision 1351616. > > As a next step one could investigate whether SvxBoxItem::SetLine() should be > changed to use the provided SvxBorderLine directly instead of cloning it. > This would save two heap operations per line. We can also reuse the existing local object. The code should be like this for(sal_uInt16 nLine = 0; nLine < 4; ++nLine) rBox.SetLine(&aLine, nLine); The local object aLine with specific info will be passed into function "rBox.SetLine" to clone.
(In reply to comment #4) > BTW: The patch has almost no risk and if it saves a significant amount of > memory then this issue should become a AOO 3.4.1 candidate. > ChaoHuang: can you give a rough estimate how much memory will be saved in a > common scenario? The amount of memory in leaking depends on the number of line object in document. There will be 4*sizeof(SvxBorderLine)=4*12byte=48byte for each line object.
I'd say the fix is great to have for the next minor release then but it is not a release blocker for the next micro release.
Since last SVT(r1400866) shows there is no memory leak, so close this defect as resolved.