Whats the best way of finding ALL your memory when developing on the Compact Framework? - compact-framework

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.

Related

Understand Heap-dump and Thread-dump for Large-scale application

I go through some tutorials of Java Profilers (JVisualVM, JProfiler, YourKit) on Youtube as well as Pluralsight. I got a little bit idea regarding how to check heap-dump and how to find the memory leak. But these all tutorials are elementary.
My query is, when I analyse in heap-dump, I saw only 3 types of objects char[], java.lang.String and java.lang.Object[] which covers almost all memory(more than 70% always). But none from my application.
And the same way for thread dump, I saw HTTP-8080 request (the port I am using) and that leads me to Runnable()'s run method or Java Concurrent Package and again not to any specific code to my project.
I also discussed the problem with some of my friends and analyse their application as well (which doesn't face any issues regarding memory leak and performance), but their results are almost the same.
Would you guys help to understand how to analyse heap-dump and thread-dump in JVisualVM for the large scale application? Any video, blog, anything would be helpful.
I am using OpenJDK-11, AWS ECS-Docker and Tomcat as a web-server.
Checkout the Eclipse Memory Analyzer (https://www.eclipse.org/mat/), I used it in the past several times to successfully find memory leaks, but it takes some time to get familiar with it.
Another advise I can give you is to create benchmark tests with Apache JMeter (https://jmeter.apache.org/) or another tool that lets you reproduce the performance/memory issue and identify the execution path that cause you problems.
Be aware AWS doesn't like when someone execute performance/penetration tests against their services (https://aws.amazon.com/aup/)

Managing LOH in vb.net

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.

Aspose PDF memory leak issue

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!

Check memory consume of vb.net application

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

Out of Memory errors - tool for finding classic ASP memory leaks?

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.