I have an vb.net application I distribute to my analysts – We assign perhaps 100 200MB images at a time. The app sequentially opens the large jpg image using GDI+ and the image is placed in the LOH. I scan each pixel looking for data. - when done I dispose the image and use GC.collect. But this does not clear the LOH, and as a result the LOH keeps increasing until the app crashes. A work around is to chop the assignment into 25 instance chunks, but this is risky as our analysts often do this late at night – perhaps after a beer or 2.
The C# construct is
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce
but there is no GCSettings available in vb.net
My vb.net code is
loadedImage.Dispose()
MasterImage.Dispose()
GC.Collect()
Finalize()
But I cannot find a vb.net method to force the LOH compaction
When done
Can you help?
GCSettings.LargeObjectHeapCompactionMode was added in .NET 4.5.1. It exists in VB.NET as well as C#. You're probably targeting a lower version of the .NET runtime. If you want access to this feature you will need to compile against a framework version of 4.5.1 or higher.
This likely won't solve the underlying problem, however. Your leak may not even be where you think it is. Profiling your application with an allocation profiler is the best way to track down resource leaks. Without a Minimal, Complete, and Verifiable example, it is difficult to guess where your application may be going wrong.
Related
I have seen many videos of code changes to a controller and then refreshing the page showing the update very quickly (1-2 seconds) and everyone is always talking about how fast Roslyn is.
I have just installed VS2014 CTP3, created a web application, hit run and then edited the message Contact action method returns.
When I hit refresh in my browser, the page takes about seconds to load (the first time, after that its instant). This the app pool starting back up and recompiling the code, but this seems a lot slower than what I have seen others experiencing.
Is anyone else having this? Could it be doing a full recompile rather than a partial recompile each time? Does anyone know how I can find out what is causing the slowness?
Thanks
I think most of the time the speed of Roslyn is compared to the speed of the previous source to il compiler. In the previous version of .NET you always pre compiled everything to il (a .net dll) which will always be somewhat slower than not pre compiling. This performance loss might be mitigated by performance gains in the il to native engine which is currently also being optimized. Depending how much needs to be compiled, jit compilation might still be to slow for your situation, so you might need to pre compile some files and or libraries.
Looking at recent merged pull requests and the fact that Roslyn is still in beta you might see considerable performance gains between the current alfa release and the RTM.
https://github.com/aspnet/KRuntime/pull/522
https://github.com/aspnet/KRuntime/issues/498
We are using Aspose PDF and are facing the following issues which are sort of show stopper:
Aspose PDF is not releasing memory. we have set object to null but they do not release memory. Result - in my web service after 20-30 calls, server memory is 100% used, and they start creating timeouts.
-- we are trying to resolve with aspose support team - but no concrete reply since last 2 weeks.
When we convert PDF to txt or HTML - this adds lot of special characters which are not recognized by our scripts.
Your help is much appreciated
just stumbled over this post while looking for a solution to a memory leak problem of my own, although this one is found within their Slides library, used for interacting with Powerpoint files. Not sure what language you're using, but this was eventually how we resolved it using .NET.
After little help from the Aspose team, we finally found that the easiest way to handle this was using a seperate AppDomain for the offending code. This has a slight performance impact, but it's only a few seconds at most so we deemed this to be acceptable. This means that after we're done, we can just call AppDomain.Unload(variable) and it will close everything down and purge the memory and this solved all the issues, we saw the memory leaking and then after the unloading occured, we saw everything released. Hope this helps!
I am getting a System.OutOfMemoryException from my vb.net application, it happened from one certain user. I am trying to figure out whether my application takes too much memory space or the PC has low memory. But she just upgraded her desktop as i3 Intel CPU and higher memory.
Is there any tool that I check memory consumption when code is executed as go through lines?
By the way, it is developed by vs2010 and It is a Windows application.
<--Edit-->
I found the problem from my application. I did not mention because I did not know what the problem was. I am using a Google map inside of vb.net application. It takes a memory whenever I search a map on web browser which is on a form . Even though I close the form, it is not disappeared from
memory. It is just going up. That goes away when I close MDI form. FYI..
The best tool we've worked so far is the JetBrains profiler (http://www.jetbrains.com/profiler/features/).
That's a common error. It normally happens when the application enters a loop that never ends... (infinite loop).
Is it a Console, WinForms, ASP, WPF?
Try to identify during which Event your application throws the exception and put a try catch to print out more details.
Just check out this cool WPF performance suite to check out if you have memory leaks:
Performance Toolkit
Or check out if you can use GC.Collect() to find the leak.
Also you can accecss in Process Explorer to any .Net memory data and peaks.
Regards
I am getting Out of Memory errors in classic ASP, probably where attempting to access data. For example:
Microsoft VBScript compilation error '800a03e9'
Out of memory
(some file) Line 0
These errors only happen once in a while and they keep happening for a few minutes and then the webserver must be restarting the app pool because all sessions are lost.
What is a good tool for finding/diagnosing memory leaks in a classic ASP application that makes heavy use of ADO for data access and a couple of other off the shelf COM objects.
Presumably any memory leaks would be from the COM object rather than the script, so a general Windows debugger or leak finder might be what I need. Any advice on what would be appropriate?
Or any other thoughts on what might cause these errors?
Unfortunately, tracking down memory leaks is not an easy task :-(
Here's a good summary of things to watch out for here:
http://www.leinadium.com/code/classic-asp-memory-leaks-in-iis/
Be sure to read the link inside that post as well for a list of tools.
Good luck!
Microsoft has a good utility umdh.exe that may be good for finding leaks in this situation. It allows you to take a "snapshot" at one point, exercise the application (e.g., IIS) then take another snapshot and compare the memory usage differences.
if
you try to get one row data with EOF OR BOF
or
the database connection is close or readony you try to wirte!
you should get the ERROR.
I've used the CF Remote Performance Monitor, however this seems to only track memory initialised in the managed world as opposed to the unmanaged world. Well, I can only presume this as the numbers listed in the profiler are way short of the maximum allowed (32mb on CE 5). Profiling a particular app with the RPM showed me that the total usage of all the caches only manages to get to about 12mb and then slowly shrinks as (I assume) something unmanaged starts to claim more memory.
The memory slider in System also shows that the device is very short on memory. If I kill the process the slider shows all the memory coming back. So it must (?) be this managed process that is swallowing the memory.
Is there any simple(ish?) fashion how one can track unmanaged memory usage in some way that might enable me to match it up with the corresponding P/Invoke calls?
EDIT: To all you re-taggers it isn't .NET, tagging the question like this confuses things. It's .NETCF / Compact Framework. I know they appear to be similar but they're different because .NET rocks whereas CF is basically just a wrapper around NotImplementedException.
Try enabling Interop logging.
Also, if you have access to the code of the native dll you are using, check this out: http://msdn.microsoft.com/en-us/netframework/bb630228.aspx
I've definitely been fighting with unmanaged issues in a C# managed app for a while -- it's not easy.
What I've found to be most helpful is to have a regular output to a text log file. For example you can print the output of GlobalMemoryStatus every couple of minutes along with logging every time you load a new form. From there you can at least see that either memory gradually erodes, or a huge chunks of memory disappeared at specific times of the day.
For us, we found a gradual memory loss all day as long as the device was being used. From there we eventually found that the barcode scanning device was being initialized for no particular reason in our Form base class (I blame the previous developer! :-)
Setting up this logging may be a small hassle, but for us it paid huge dividends in the long run especially with the device in live use we can get real data, instrumentation, stack traces from exceptions, etc.
Ok, I'm using C++ on CE, not C# so this may not be helpful, but...
I use a package called Entrk toolbox which monitors memory and resource usage, leaks, and exceptions under Windows CE. Pretty much like a lightweight CE version of boundschecker. Does the trick most times.