Zooming Memory Leak

SyntaxEditor for WPF Forum

Posted 15 years ago by Cameron MacFarland - Senior Software Engineer, Orelogy Geotechnical
Avatar
There seems to be a memory leak in the Zooming sample. If you open the sample, and then zoom the text in and out the memory usage just keeps climbing, and several exceptions are thrown.
A first chance exception of type 'MS.Internal.FontCache.FontCacheFullException' occurred in PresentationCore.dll
A first chance exception of type 'System.OutOfMemoryException' occurred in PresentationCore.dll
A first chance exception of type 'MS.Internal.FontCache.FontCacheFullException' occurred in PresentationCore.dll
These three lines are repeated in my debug window when zooming.

Otherwise, keep up the good work.

[Modified at 01/29/2009 08:33 PM]

[Modified at 01/29/2009 08:34 PM]

Comments (8)

Posted 15 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
I thought I'd mention that I cannot duplicate this. I am still on the original alpha build (not the updated build from today). I also ran this in my own application instead of in the Sample project. I placed large amounts of text in the editor and constantly scrolled in/out. I saw memory utilization move up, but then it would recover (as expected). I never saw any exception and memory never grew significantly beyond the starting base.

OS: Windows 7
.NET Framework: 3.0

Perhaps the issue is not with SE but with the binding between SE's zoom level and the slider bar in the sample application.

I played around with the sample app and did notice on consistent increase in Working Set memory, but the Private memory stayed constant. I'm no expert on memory usage or memory leaks (or the Garbage Collector for that matter), but it's possible the working memory was increasing simply because the GC had not kicked in and plenty of free memory was still available. After sitting idle for a 15-30 seconds, the working memory dropped back down (which makes me think GC ran).

Anyway... just wanted to throw in some more insight.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Cameron,

I was just doing some profiling with .NET Memory Profiler (memprofiler.com) and ran the Zooming QuickStart and did mouse wheel zooming for a while. I did a snapshot before and after a minute or so of zooming and checked memory. The live instance memory seemed about the same before and after. Any memory increases you see are likely waiting to be garbage collected. I don't get the exceptions either.

I checked the places we create fonts and at run-time there really is only one place that makes font allocations during usage. And that caches fonts (in our code) as you use the control so once the font is created for a style, it grabs the existing font from our cache. So I'm not sure how we would really be contributing to a system font cache filling up.

Is anyone else seeing this happen?


Actipro Software Support

Posted 15 years ago by Cameron MacFarland - Senior Software Engineer, Orelogy Geotechnical
Avatar
Ok, it looks like there's a leak in the text animation code for WPF.

I'm using Windows XP SP2 with .NET 3.5 SP1.

The code posted by Gabriel Sinkin on this page causes the same exceptions and memory leak.

Hope that helps.
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Cameron,

Can you post some more details like which OS you use, .NET framework, system theme, etc.

Also how exactly are you reproing it and how long does it take you to do so? For instance, are you using the mouse wheel or a slider?

Thanks!


Actipro Software Support

Posted 15 years ago by Boyd - Sr. Software Developer, Patterson Consulting, LLC
Avatar
Sounds like we might need an option to turn animation on/off for zoom. This could actually be useful for tuning SE to work well on low-end machines where the animation would not be as smooth. In other words.. if it won't look good we can turn it off.

I haven't looked at the object model yet. This might already be an option :)
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
You can set the zoom animation duration to 0 to disable animation. In that QuickStart change 300 to 0 to do it and tab off the textbox. I'd be interested to know if that resolves it for Cameron.


Actipro Software Support

Posted 15 years ago by Cameron MacFarland - Senior Software Engineer, Orelogy Geotechnical
Avatar
I've noticed the issue with both zooming the slider, and mouse wheel zooming.

The issue takes a bit of zooming before it turns up. The memory usage doesn't climb rapidly, and I'm on a 4GB machine. The fastest way to trigger the issue is to zoom in and out gently rather than rapidly.

I'll try turning off the animation on Monday when I'm back at work.
Posted 15 years ago by Cameron MacFarland - Senior Software Engineer, Orelogy Geotechnical
Avatar
Ok, this problem goes away if the delay is set to 0. There's still a bit of a leak, but it's not as bad, and there are no more exceptions.
The latest build of this product (v24.1.1) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.