Issue 119997 - [From Symphony] [MemoryLeak]There is a memory leak in function WinGlyphFallbackSubstititution::FindFontSubstitute
Summary: [From Symphony] [MemoryLeak]There is a memory leak in function WinGlyphFallba...
Status: CLOSED FIXED
Alias: None
Product: performance
Classification: Code
Component: www (show other issues)
Version: AOO 3.4.0
Hardware: PC Windows, all
: P3 Normal (vote)
Target Milestone: 3.4.1
Assignee: issues@performance
QA Contact:
URL:
Keywords:
Depends on:
Blocks: 120975 121366
  Show dependency tree
 
Reported: 2012-06-15 05:06 UTC by ChaoHuang
Modified: 2013-02-16 09:20 UTC (History)
5 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---
jsc: 3.4.1_release_blocker+


Attachments
for file "main\vcl\win\source\gdi\salgdi3.cxx" (774 bytes, patch)
2012-06-15 08:07 UTC, ChaoHuang
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description ChaoHuang 2012-06-15 05:06:18 UTC
(1) Code snippet in function WinGlyphFallbackSubstititution::FindFontSubstitute:
-------------------------------------------------------------------------------
        // last level fallback, check each font type face one by one
	const ImplGetDevFontList* pTestFontList = pDevFontList->GetDevFontList();
	// limit the count of fonts to be checked to prevent hangs
	static const int MAX_GFBFONT_COUNT = 600;
	int nTestFontCount = pTestFontList->Count();
	if( nTestFontCount > MAX_GFBFONT_COUNT )
		nTestFontCount = MAX_GFBFONT_COUNT;
	
	for( int i = 0; i < nTestFontCount; ++i )
	{
		const ImplFontData* pFace = pTestFontList->Get( i );
		if( !HasMissingChars( pFace, rMissingChars ) )
			continue;
		rFontSelData.maSearchName = pFace->maName;
		return true;
	}

	return false;

(2)Memory Leak :
--------------------------------------------------------------------------------
The pTestFontList will be created in function ImplDevFontList::GetDevFontList(), which will new an object typed ImplGetDevFontList on heap. The pTestFontList will not be released when return from function WinGlyphFallbackSubstititution::FindFontSubstitute
Comment 1 ChaoHuang 2012-06-15 07:34:32 UTC
Steps to reproduce the issue:
1) Launch Aoo3.4
2) New a odt file
3) Close the odt file

Defect : There is a memory leak in function WinGlyphFallbackSubstititution::FindFontSubstitute
Comment 2 ChaoHuang 2012-06-15 07:58:57 UTC
Need to free pTestFontList explicitly.
Comment 3 ChaoHuang 2012-06-15 08:07:59 UTC
Created attachment 78338 [details]
for file "main\vcl\win\source\gdi\salgdi3.cxx"
Comment 4 hdu@apache.org 2012-06-15 09:34:53 UTC
Thanks for the find and for the patch! Applied as rev 1350553 with minor style adaptions to surrounding code.

In the future there is potential for more performance gains when GetDevFontList() gets modified to return a read-only reference of the list.
Comment 5 Li Feng Wang 2012-06-26 08:19:09 UTC
add MemoryLeak tag for this defect.
Need long time running to verify.
Comment 6 jsc 2012-07-02 11:51:03 UTC
set release blocker flag for 3.4.1
Comment 7 hdu@apache.org 2012-07-02 14:08:34 UTC
Also applied ChaoHuang's patch for AOO 3.4.1 as revision 1356233
Comment 8 Yan Ji 2012-11-30 04:47:17 UTC
Since last SVT(r1400866) shows there is no memory leak, so close this defect as resolved.