Issue 119997

Summary: [From Symphony] [MemoryLeak]There is a memory leak in function WinGlyphFallbackSubstititution::FindFontSubstitute
Product: performance Reporter: ChaoHuang <chao.dev.h>
Component: wwwAssignee: issues@performance <issues>
Status: CLOSED FIXED QA Contact:
Severity: Normal    
Priority: P3 CC: hdu, issues, jsc, liushenf, phoenix.wanglf
Version: AOO 3.4.0Flags: jsc: 3.4.1_release_blocker+
Target Milestone: 3.4.1   
Hardware: PC   
OS: Windows, all   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---
Issue Depends on:    
Issue Blocks: 120975, 121366    
Attachments:
Description Flags
for file "main\vcl\win\source\gdi\salgdi3.cxx" none

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.