.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Post New Web Links

InteropBitmap memory leak

Posted By:      Posted Date: September 16, 2010    Points: 0   Category :WPF
Goal : Create a scrolling wave form that has a low overhead (WPF) Challenges : Huge bitmaps are not accepted by Image.Source Smaller (but still very big bitmaps) are accepted but overall UX is terrible. Memory conservation Scrolling must be at 60fps Problems encountered : Used GPU memory amount is insane ! (400 to 800 Mb each 10 seconds) So here's what I did : I am rendering that bitmap through an Image.Source that I created with Imaging.CreateBitmapSourceFromMemorySection (which type is InteropBitmap). I have loaded that big bitmap in memory and every time I need to update, I do a CopyMemory then I do InteropBitmap.Invalidate(), so far it's perfect and performance is excellent. That particular type of BitmapSource is said to be the fastest, and it is actually; but after some profiling, it litterally eats GPU memory, as said above. It seems that InteropBitmap never recycles GPU memory, or caches it, I don't know... On my Win7 x64 machine, I have 4Gb of which up to 1.5Gb can be used by the GPU. (Laptop is a Thinkpad T61p with dual-core at 2.5Ghz and a Quadro FX570M with 256Mb) My first and safer solution was to use a WriteableBitmap which works good but no 60 fps here, What do you suggest ? Shall I go WinForms for required performance ?   Thanks for your help !

View Complete Post

More Related Resource Links

Memory leak?


I’m not sure how I should consider my problem. I’m developing workflow with VS 2008 for MOSS 2007. I’ve created simple method which remove security group “MyGroup” from the item. And it seems that it works:

private void UsunDziedziczenieUprawnien_ExecuteCode(object sender, EventArgs e)


            using (SPSite site = new SPSite (workflowProperties.SiteId))

WmiPrvSE.exe causes a huge memory leak in SQL server 2008 R2, why?

My OS is windows server 2008 r2 data center 64 bit and my SQL server is server 2008 R2. The problem is when I open sql server, the WmiPrvSE.exe process consumes 20 - 60kbs every second. Several hours later, it eats up at least 200mbs memorry and this process seems like it will never stop. Can any experts give me some ideas to fit this mess? PS: My mainboard is Asus striker II formular, cpu is intel quad-core. Also, all my software are updated to latest version.

Memory leak on binding to a WPF TreeView

We're having an issue with a TreeView hanging onto a viewmodel set that has been bound to it. We have a static treeview on the main window, and reset its ItemsSource to Nothing or a new viewmodel when new things need to be displayed. The problem seems to be that it's hanging onto the first item that it was bound to, even after the ItemsSource is set to nothing. The connection seems to be through some strange unknown binding that's in the EffectiveValues collection of the TreeView.   I was able to repro this in a test project, so I'll post the simplified code:   TreeView templates:   <Window.Resources> <HierarchicalDataTemplate DataType="{x:Type local:ParentViewModel}" ItemsSource="{Binding ChildVMs}"> <TextBlock Text="{Binding Name}"/> </HierarchicalDataTemplate> <DataTemplate DataType="{x:Type local:ChildViewModel}"> <TextBlock Text="{Binding Name}"/> </DataTemplate> </Window.Resources>   ViewModel definitions: (Shared Function to generate the itemssource for the treeview)   Public Class ParentViewModel Public Shared counter As Integer = 0 Public Shared Function GenerateViewModel() As List(Of ParentViewModel) Dim pvm As New ParentViewModel With {.Name = "Parent" & counter} ' Unique name pvm.ChildV

SharePoint memory leak (8l1n)

hi , I'm annoied with the memory leak problem these days. the following text is copied from the ULS log. Does anyone can read this?  or pick up some clues out of it?

it's high appreciate for your help!

8l1n High     An SPRequest object was not disposed before the end of this thread.  To avoid wasting system resources, dispose of this object or its parent (such as an SPSite or SPWeb) as soon as you are done using it.  This object will now be disposed.  Allocation Id: {BE9269D2-BE0D-4A94-BBD9-71FD642892F2}  This SPRequest was allocated at    at Microsoft.SharePoint.Library.SPRequest..ctor()     at Microsoft.SharePoint.SPGlobal.CreateSPRequestAndSetIdentity(Boolean bNotGlobalAdminCode, String strUrl, Boolean bNotAddToContext, Byte[] UserToken, String userName, Boolean bIgnoreTokenTimeout, Boolean bAsAnonymous)     at Microsoft.SharePoint.SPWeb.InitializeSPRequest()     at Microsoft.SharePoint.SPWeb.EnsureSPRequest()     at Microsoft.SharePoint.SPWeb.get_Request()     at Microsoft.SharePoint.SPListCollect... 
09/21/2009 13:16:35.11* w3wp.exe (0x1780)                        0x13D0 Windows SharePoint Services    General                        8l1n High     ...ion.EnsureListsData(Guid webId, String strListName)     at Microsoft.SharePoint.SPListCollection.EnsureListsData(String strListName)     at Microsoft.SharePoint.SPListCollection.ItemByInternalName(Strin

VS 2010 memory leak?


It happens frequently when I try to copy & paste code inside VS 2010 with following message:

insufficient available memory to meet the expected demands of an operation at this time, possibly due to virtual address space fragmentation. Please try later.

and I check the memory usage with taskmanager on my computer. It is fine.

In order fix it, I need to close VS 2010 and restart again.

So is it a memory leak or can be fixed in some way?

Workflow Designer 4.0 Load() Performance Issue: possible memory leak?


Hello everybody,

I am trying to implement a workflow designer in a windows form application and use the same designer to view different workflows. However, I found the program became slower and slower after loading several workflows.

my steps are as follows:

1. create a wpf user control WFDesigner to package the workflowdesigner;

2. In the user control  WFDesigner , implement a InitiateDesigner method which create a new workflowDesigner instance each time called. I suppose the old workflowDesigner instance would be collected by GC;

3. create a winform application and install the user control created on step 2 to an element host, and put the element host on the form. 

4. add two buttons for test: one will execute  WFDesigner.InitiateDesigner() once and the other will execute it 100 times.

ResXResourceReader memory leak?


I have occasion in my program to compile some CSharp code on the fly, with embedded resources from a .resx file. To do this, I use a System.Resources.ResXResourceReader to read the ResX file and a System.Resources.ResourceWriter to create the binary resource file. However, when I step through the code, I find that ~15MB of memory gets taken up when the ResXResourceReader reaches a Node whose value is a Bitmap, and that memory doesn't get freed even if I explicitly dispose the Bitmap. The ResXResourceReader is getting disposed (it's declared in a using statement). How can I keep this memory leak from happening? Here's the code where I read through the ResX file:


using (System.Resources.ResourceWriter Writer = new System.Resources.ResourceWriter(FileName = System.IO.Path.GetTempPath() + ClassName + ".resources"))

using (ResXResourceReader ResXReader = new ResXResourceReader(this.ResourceFileName))
                foreach (System.Collections.DictionaryEntry Node in ResXReader)

Is this a Memory Leak?



I am developing an app using the MVVM model and I am doing something which I think might create a memory leak.

Basically I have a master ViewModel which contains an ObservableCollection<Child1ViewModel>. Then, each Child1ViewModel contain an ObservableCollection<Child2ViewModel> and so on. I have 4 layers like that.

Each layer contains a reference to its parent. I added a "Delete Self" Command to Child2ViewModel, in a way that it removes itself from its parent's collection:

private void DeleteSelf()
  //First I delete the item through the model:

  //Then I need to remove it from the parent's viewmodel collection:

this.Parent.Children is the ObservableCollection<Child2ViewModel>. Since I am within the element I am deleting, when I remove it from the collection, will the garbage collector detect this and trash the object since the only reference to it was within the ObservableCollection? Or will it not kick in since i'm actuall

How to avoid memory leak when removing a tabitem with usercontrol as content



I am using tabcontrol with tabitems having usercontrols as content.

When I remove a tabitem, I can see that the memory is not freed. I saw this problem has been discussed, but I have not found a complete response. I tried to do in this order, as suggested in some discussions in the forum:




.TabControlTest.Items.Remove(ti); // ti is a TabItem

ti.Content =

Memory leak in .net framework


Hi All,

is it possible to have memory leak in .net framework.If we are using any unmanaged code then there is a possibility, but what if our application is complete a managed application.Is there any chances of memory leak in case of managed code and if "there is a chances" then Can you please explain me how is that possible.Thanks for any help

How to detect and avoid memory and resources leaks in .NET application

Despite what a lot of people believe, it's easy to introduce memory and resources leaks in .NET applications. The Garbage Collector, or GC for close friends, is not a magician who would completely relieve you from taking care of your memory and resources consumption.

I'll explain in this article why memory leaks exist in .NET and how to avoid them. Don't worry, I won't focus here on the inner workings of the garbage collector and other advanced characteristics of memory and resources management in .NET.

file upload in chunks or not buffering in memory before writing to disk?


What are the options for handling file uploads to reduce the memory footprint?  Is there a way to upload in chunks?  Is there a way to stream upload directly to disk instead of loading entire file in server memory?


Visual Studio 2008 Memory problems


My memory in task manager reaches about 900,000K  and I don't know why it does this. Definately slows everything down, especially when I rebuild my tableAdapters, takes about 30 seconds sometimes to rebuild the project.

Crystal Report gives System.AccessViolationException: Attempted to read or write protected memory. T


when a crystal report for same id is opened again at same time or refreshed then it gives the

"System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stack Trace is :-

Stack Trace:

[AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
CrystalDecisions.ReportAppServer.Controllers.DatabaseControllerClass.SetConnectionInfos(ConnectionInfos ConnectionInfos) +0
CrystalDecisions.CrystalReports.Engine.Table.ApplyLogOnInfo(TableLogOnInfo logonInfo) +362
CrystalDecisions.CrystalReports.Engine.ReportDocument.SetTableLogon(Tables tables, String user, String password, String server, String database, Boolean ignoreCase) +258
CrystalDecisions.CrystalReports.Engine.ReportDocument.SetDatabaseLogon(String user, String password, String server, String database, Boolean ignoreCase) +204

Maximum memory for string ? . System.MemoryOutOfException Occurs when reading the Content of the fil



I have a C++ code which reads a file [vtk file - its similar to text file only]. and try to store it in string.

here's the code:

String^ ParallelProjectionRenderer::GetVolumeDataAsString(String^ FileName)

    vtkSmartPointer<vtkDataSetWriter> sWriter = vtkSmartPointer<vtkDataSetWriter>::New();

    String^ FileName = "D:\\Users\\...";

    char * sptName = static_cast<char *>(Marshal::StringToHGlobalAnsi(FileName).ToPointer());







    String^ result= File::ReadAllText(FileName);   [it breaks here with system.memoryoutofexception when the file size is huge]

    return result;


this code executes fine when the file size is less than 8mb.

I wanted to know whats the maximum memory allocated to the string.

As a workaround i skipped reading out in C++ code. and i tried to read the file contents in asp.net C# code and stor

Tools for memory error check in VS2005


Dear all,

I am going to write vs2005 program with ASP.NET and C++.

As you know that C++ will involve a lot of memory error handling.

Do you know is there any tools for checking memory error in Code Behind C++??

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend