Memory profiling tools - memory-management

Hi
I am trying to find a memory leak issue at a client site. They are using our application and over time while using it the application runs out of memory and throw an OutOfMemory exception. It would not be easy to replicate the issue inhouse since we will have to sit for hours to replicate their workflow. So I need to put a tool (possibly free) on their machine which should be able to tell me how the memory is being uesd by the application and some generation infor. So doen anybody know of a tool that can achieve this or can anybody point me in a direction that can help me find the problem without profiling the whole application in dev env

Assuming Java, you can set the -XX:+HeapDumpOnOutOfMemoryError flag, which will cause the JVM to dump the heap when it throws out of memory exceptions. Then, you can take the dump and run it through jhat to see where the memory is being allocated. (There's also an Eclipse based heap dump analysis tool.) I've used this in the past with great success.

It so happens that the new CLR Profiler with support for .NET 2.0 through 4.0 was just released by Microsoft:
David Broman's CLR Profiling API Blog: CLRProfiler V4 Released
It's free.

Related

WebSphere - built-in memory profiler

I have tried some java profilers to profile WAS memory, but I guess due to the all SUN/IBM java thing, they don't support WAS.
Is there any built-in way to profile memory / analyze the heap dump a bit more / something in tracing and monitoring, perhepas?
If not, I know of some products - but the things is that we are in a closed enviornment - I can't just download and run. So if there is anything that comes with WAS, I would like to know.
Thank you.
Check out the HealthCenter
http://www.ibm.com/developerworks/java/jdk/tools/healthcenter/
It should be a reasonable one for you!
I am not aware of any profiler that comes with WebSphere but you can download IBM Support Assistant (Free) and download the HeapAnalyzer which is very good for analyzing heap dumps.
Personally I did not try v5 yet but used the heap analyzer a lot.I
There is no built-in thing to do that, but IBM offers a graphical GC and Heap Analysing Tool. You will have to download it from IBM.
Please have a look here:
https://www.ibm.com/developerworks/java/jdk/tools/gcmv/
The Eclipse Memory Analyzer can analyse both IBM and non-IBM heap dumps. It's also available in the IBM Support Assistant as a supported tool.

How can I profile the memory usage in a wp7.1 background agent?

I'm working on a scheduled background agent for Mango (7.1)
I've managed to cut my memory usage down from 10.5MB to 6.5MB using manual trace techniques based on DeviceStatus.ApplicationPeakMemoryUsage along with some intelligent guesswork about what to optimise.
However, now I need to get down to below 6MB - and the final 0.5MB is proving elusive.
I've managed to run the "Windows Phone Performance Analysis" tool on the main app, but can't seem to find a way to get it to run against the agent.
Are there any tools and/or techniques available to assist me in working out what is filling up my agent's memory? Ideally I'd like a way to investigate the entire memory space - including both code and data, and ideally it should work against a release build.
As has already been said, the debugger will add a non-negligible memory overhead. So the best way I found is:
Activate the emulator's console: http://nicksnettravels.builttoroam.com/post/2011/01/19/Windows-Phone-7-Console-Window-on-64-bit-machine.aspx
At strategic points of your code (beginning and end of the main functions for example, or after allocating a big object), display the memory consumption:
Console.WriteLine("Function {0}: {1}", "name of your function", DeviceExtendedProperties.GetValue("ApplicationCurrentMemoryUsage"));
Start the application without attaching the debugger (Ctrl + F5), sit back and enjoy
Remember if you are running the background agent in Debug mode this adds about 2MB onto the memory footprint of the agent, so you might be OK.
You could probably use the ApplicationPeakMemoryUsage still and write the memory details out to a file in Isolated Storage when running the app directly, rather than from Visual Studio.
HTH - Rupert.
You may find the following blog post interesting, you may have already seen it but it describes both the debug memory addition as well as some tips to decrease the memory footprint.
http://www.pitorque.de/MisterGoodcat/post/Windows-Phone-Background-Agents-Pitfalls-(2-of-n).aspx

performance problem - growing memory and cpu usage

I have windows application I wrote.
I installed it on virtual server (vmware) that holds windows server 2008 and for some reason the application getting bigger and bigger. I used perfmon in order to see maybe there is a memory leak - but as I understand, there isn't:
Here is the proccess in task manager:
There are also two proccesses that use a lot of memory and cpu but are steady and not growing like SimeserManager.exe.
The memory growing slows the surfing on sited that this server holds.
Before this week I used the my application on phizical server with windows server 2003 and there were no problem with surfing. I can't restore the situtaion in the phizical machine since I don't have it anymore, but I don't believe there was memory error when using the phizical server.
The application is written in c# .net using visual studio 2010.
What can be the problem?
Where can I get some clues?
UPDATE
I get ANTS memory profiler and tried to seek for the problem. I created memory snapshots and here is the results:
Now I'm really lost.
I tryed the standart filters but didn't manage to find a clue for the problem. In the image you can see there is increase in the private bytes. Does that sais there is a memory leak?
Can anyone give me some clues how to continue?
Thanks!
We don't have enough information here to really debug your application. However, there are tools you can use to identify and solve this issue in your application. I would suggest you use the ANTS Memory Profiler from RedGate to help you look for your problem. Here is a link to it:
http://www.red-gate.com/products/dotnet-development/ants-memory-profiler/
It isn't free but it is cheap and extremely effective. Get the 14-day free trial and run it on your application. I would go as far as to say that if it doesn't find the issue, the issue probably isn't with your application.
As for the other processes that are taking a lot of memory, this is normal. SQL Server tries to get as much memory as possible. Running other applications on the same box as a SQL server may cause you performance issues if you aren't careful. Here is a good article on how SQL Server uses memory:
http://sqlblog.com/blogs/jonathan_kehayias/archive/2009/08/24/troubleshooting-the-sql-server-memory-leak-or-understanding-sql-server-memory-usage.aspx
As for IIS memory usage (the other process that was using lots of memory), there could be multiple reasons for this. I would suggest you read through this forum to get a better idea of what it could be (if it truly is an issue):
http://forums.iis.net/t/1150494.aspx

What rarely used debugging tools you found useful?

What rarely used debugging tools you found useful ?
My recent debugging situation on Visual Studio required trapping the breakpoint on fresh built 32-bit DLL, which was loaded by GUI-less executable, which was spawned by COM+ server on remote x64 machine, which was called through RPC from actual GUI. As usual, all worked well on all 32 bit machine, but kept failing on "machine other than development one". So remote debugging was inevitable.
So after scratching the head beaten against wall for 2 days, I have added 10 sec delay into DLL attach entry point and used Microsoft Remote Debugger wich I never used before. It saved my day.
Another favorite: Java JMX console as a performance "debugging" tool. You can see all threads, memory chart, have a snapshot of any thread stack any time you click. Clicking several times helps to find what exactly is slow in J2EE application.
Process Monitor and other Mark Russinovich's tools.
A logic analyzer plugged to CPU pins and able to disassemble executed code. I tracked a bug in the boot sequence of an embedded system.
I find printf to be the most useful.
These - in my experience at least - do not seem to be the intuitive first choice for many when debugging apps accessing a database (i.e. the majority), that perhaps they should be :
SQL Profiler (SQL Server)
TKPROF (Oracle)
Another interesting combination was using eclipse running in a virtual machine, accessing a remote server, attaching to the Tomcat process there; and doing it from two different machines to debug two different packages simultaneously.
All time favorite is depends.exe, for finding out why a dll or exe is not starting http://dependencywalker.com/
For performance, at my former job we used to have really simple to use C++ macro's that did statistics on runtime function calls. This is so much better than a profiler, because you can use it from your regular IDE, and it allows you to zoom in on the code you are optimizing.
In my new job, I wrote a C# version of the same idea.
WinDbg and other lower level debuggers are the ultimate weapon if you know the tricks and tips.
For Windows/.Net development I am always using Debugview and Ildasm.

IBM RAD 7 and Websphere 6.1 is slow and unresponsive

How can I improve performance when developing locally with Websphere and RAD? I am using one web application of moderate size (1000? classes) and it is impossible to handle the app locally on a Windows box. The Websphere 6.1 configuration uses the default configs. RAD7 is configured to handle a max heap of 1024mb. I thought about increasing the heap of the server. At present, the min and max are 128/300mb.
In terms of unresponsiveness, sometimes it may take minutes to load a page, if the page loads at all. Also, I disabled "Build Automatically" and Publish Automatically. Maybe those should be turned on?
I'm not sure about RAD7 but from my past experience, I'd suggest to give MyEclipse Blue a try.
Since that might not be an option, here are some other usual culprits, you can check:
How much RAM does your machine have? It's good to give WS 1GB of RAM but if your computer only has 1GB of real RAM, it's going to swap itself to death. If your boss won't pay for it, go get some RAM with your own money. 2GB are less than $80 ATM. I suggest to get at least 4GB. Yes, Windows can only use 3.5GB even when 4 are installed but that half GB costs $20 or less. Even thinking about this for more than five minutes will cost more than simply buying it.
Next make sure whether you are using the correct Java GC options. There should be some info about this in the docs. Plus make sure that the process uses the "jvm.dll" from the "server" directory, not the "client" one. "Process Explorer" will help.
Since I'm not using RAD, I'm not 100% sure about "Build Automatically" and "Publish Automatically" but since RAD7 is based on Eclipse, these options will compile code in the background as you type. This will greatly reduce the time between you saving your last change and the moment the app server can start to load the new code.
When all else fails, run websphere in a profiler and look where it spends all the time.
Aaron had great advice.
I would also suggest using JConsole to see what is going on, to help you determine if you need more memory, larger heap size, etc. My experience with running Websphere and RAD locally is that it will be slow, but then I was on an old machine that needed more memory. :)
http://java.sun.com/j2se/1.5.0/docs/guide/management/jconsole.html
Berlin,
RAD 7 saps your PC! When I was using it to develop Portlets, I followed this optimization guide and it made the IDE significantly quicker to develop Portlets in. Obviously it is aimed at Portlet development but it might help you.
Also following the advice given to the answer to this question will also help.
I definitely agree with Aaron Digulla. You will see a major performance improvement with 4GB RAM installed on your development machine. I developed an Eclipse/RAD plugin with some buddies of mine and we were able to measure how much time we saved by upgrading from 2GB to 4GB.
The plugin is available here: http://lopb.org/
After gathering some hard numbers on how much time we spent waiting for publishing and loading the app on our 2GB development machines, we were able to convince management to upgrade the rest of the developers on the team.
Anyway, you should really consider upgrading to 4GB if you want to run RAD 7 and Websphere 6 on the same development machine. Each one needs -Xms=512m -Xmx=1024m as JVM args to run well, and that means you will swap to disk way too much if you only have 2GB of RAM or less. HTH
Make sure your running was in development mode for your development and testing.
Option is under the server in the console.
Karl
hehe, we had the same problem with RAD6 and Websphere 6.
The way we speeded things up is moved to Eclipse and JBoss.
We developed on Eclipse and JBoss and then first round of testing was on Websphere. We had some issues with the differences but would never had completed the project were it not for out switch (a lot fewer issues than deving on RAD/WAS).
But to help you in the mean time...
Definitely, probably want build automatically and publish automatically off. That way you can make a bunch of changes and then tell RAD to compile and deploy while you go and get coffee.
There is a "run in dev mode" in Websphere (I know there was for 6.0) so track that down and turn it on (it's on the WAS console somewhere)
I found WAS's on stack replacement to work fairly well. I found that at the beginning of the day I'd deploy to WAS and then not have to redeploy at least until lunch time (as I was debugging). I would make changes and the changes would be fed to the server without my having to redeploy.
Chances are, even after running the profiler you'll find there's nothing much that you can do..
Turn off all validations (in RAD), they tend to take forever.
Depending on what you're doing with EE investigate the possibility of deving on another IDE/Server combo, maybe you can do the bulk of your work in there and then deploy from RAD/WAS to do some final testing. If you're using vanilla ejb's or web services this is feasible.
That max heap does sound a bit small to me. The suggestion to fire up JConsole is a good one cause it will tell you how much heap is being used, though I'm not sure if it will work on the IBM vm (RAD's). You might try and turn on the memory usage monitor in RAD, tells you how much memory is being used, that way you can tell if it's hitting the max.
JConsole will not work without specifically enabling it via a JVM command line switch.
Suggestions from Michael Wiles sound reasonable but please update your RAD first to the latest FixPack available.
You can also contact support.

Resources