SyntaxEditor memory needs

SyntaxEditor for WPF Forum

Posted 11 years ago by 7Alpha7
Version: 13.1.0583


I have a development studio with MDI interface, with full intellisense and parsing features in c#. As soon as I open a SyntaxEditor in an DocumentWindow with only few lines of code, the memory use increases by appoximately 20 Mo. If I open two, 20 Mo more... Is it normal ? It's too much !

Also, I have a solution with several projects, and for each project I assign a different instance of the CSharpSyntaxLanguage, so that the intellisense be separated. But, the memory space is also enormous ! I have a solution with 14 projects, and it's too much of memory for 14 instances.

Thank you.

Comments (4)

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA

It's hard to say what's going on in your situation.  What you should do is get a good .NET memory profiler like the one at  Then you can use that to see exactly what objects are being held in memory.  If you do that and end up seeing that something in our assemblies is causing the problem, please make a new very simple sample project that shows the issue and send that to our support address.  Reference this post and rename the .zip file extension so it doesn't get spam blocked.  Thanks!

Actipro Software Support

Posted 11 years ago by 7Alpha7

I tried to profile the memory with VS profiler but it was not interesting. I could just see that the Activate() method of the ActiproSoftware.UIStudio.Dock.DocumentWindow containing the SyntaxEditor was the last operation before the leak. I have to say that I use the UIStudio for docking features and SyntaxEditor with windows WPF interop through an ElementHost.

I have other DocumentWindow with no SyntaxEditor and there is no such memory usage, even hosting a Windows Form designer or a Workflow designer. But there is no interop with ElementHost in that case. Could this be a cause of huge memory usage ?

Anyway, with the VS profiler and the use of 14 instances of CSharpSyntaxLanguages, it was pointed out that the memory was used by those latter.

[Modified 11 years ago]

Posted 11 years ago by Actipro Software Support - Cleveland, OH, USA

I wouldn't think that interop would pose an issue.  Nor would I really think that newing up a lot of languages would either.  But if each of those languages is loading binary reference data for 20-30 different assemblies (so that the resolver can do IntelliPrompt) then that certainly can start to add up memorywise.  But again, you can't really know unless you use a proper .NET memory profiler.  Try the one at  I believe there is a free trial and it's very good for this specific thing, and gives very accurate results.

Actipro Software Support

Posted 11 years ago by 7Alpha7

It's true I have some external assemblies to resolve so that intellisense can work. However I have few bugs (if I use the repository it works the first time but once the repository exists I have an exception thrown by an Actipro type on a specific assembly passed to AssemblyReferences : NotImplementedMemberException or something like this) and I am not sure yet about the cause so I will open a thread later about this specific case.

I tried to profile memory with .Net memory profiler but the results are not clear. The problem is that I have too many new instances between the two snapshots : the one without any SyntaxEditor open and the second with a SyntaxEditor displaying a small C# source code. As far as I can see its seems to be the Byte[] type witch is the more greedy with 6.10^6 bytes and 60 instances delta.

The largest new Byte[] instance is one of 6 122 558 bytes and is hold by the BackGround property of a AvalonAdapter type instance which seems to be the parent of the SyntaxEditor and of an ElementHost instance also. Here is the call stack :

System.IO.MemoryStream.set_Capacity( int )
System.IO.MemoryStream.EnsureCapacity( int )
System.IO.MemoryStream.SetLength( long )
[Managed to native transition]
System.Drawing.SafeNativeMethods.Gdip.GdipSaveImageToStream( HandleRef,IStream,ref Guid,HandleRef )
System.Drawing.Image.Save( Stream,ImageCodecInfo,EncoderParameters )
System.Windows.Forms.Integration.Convert.ToSystemWindowsMediaImagingBitmapImage( Image )
System.Windows.Forms.Integration.ElementHostPropertyMap.UpdateBackgroundImage( ElementHost )
System.Windows.Forms.Integration.PropertyMap.RunTranslator( PropertyTranslator,object,string,object )
System.Windows.Forms.Integration.PropertyMap.OnPropertyChanged( object,string,object )
System.Windows.Forms.Control.UpdateBounds( int,int,int,int,int,int )
System.Windows.Forms.Control.WmWindowPosChanged( ref Message )
System.Windows.Forms.Control.WndProc( ref Message )
System.Windows.Forms.Integration.ElementHost.WndProc( ref Message )
System.Windows.Forms.NativeWindow.Callback( IntPtr,int,IntPtr,IntPtr )
[Native to managed transition]
[Managed to native transition]
System.Windows.Forms.SafeNativeMethods.SetWindowPos( HandleRef,HandleRef,int,int,int,int,int )
System.Windows.Forms.Control.SetBoundsCore( int,int,int,int,BoundsSpecified )
System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.SetBounds( Rectangle,BoundsSpecified )
System.Windows.Forms.Layout.DefaultLayout.xLayoutDockedControl( IArrangedElement,Rectangle,bool,ref Size,ref Rectangle )
System.Windows.Forms.Layout.DefaultLayout.LayoutDockedControls( IArrangedElement,bool )
System.Windows.Forms.Layout.DefaultLayout.xLayout( IArrangedElement,bool,ref Size )
System.Windows.Forms.Layout.DefaultLayout.LayoutCore( IArrangedElement,LayoutEventArgs )

 It seems that at least a part of the problem comes frome the interop... I will dig further.

[Modified 11 years ago]

The latest build of this product (v24.1.2) was released 3 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.