My silverlight application is taking up 75 megs of memory. This seems high. How can I troubleshoot the application to see where the memory is being used. Is there any trick like running a low memory mode that would reduce my footprint for S light!
#Matt Bridges suggestion for a profiler is correct. I have also used ANTS. Other alternatives include Yourkit and using WinDbg SOS.
There isn't one answer to your question so it might get closed, however, there are memory leaks with inline Data Templates in your controls. Here is an example, but there are lots of pages when you google for it: http://www.devtoolshed.com/silverlight-memory-leak-datagrid-dataform-datatemplate-etc
One place to start is the ANTS Memory Profiler, which works with Silverlight.
Related
Is it possible to Log.p("amount of Ram consumed"); by an app?
And Log.p("amount of Storage used"); by an app?
Yes but not reliably. Devices are pretty problematic with RAM allocations per app as they sequester memory in ways that are very unclear. Runtime.freeMemory should work with the current iOS VM and produce "something" but I'm not sure how valuable that will be.
Keep in mind that the GC in all platforms will cause issues as there is no guarantee System.gc() will do anything or how long it will take to do whatever it is that isn't guaranteed...
If you want to check memory leaks in your app I suggest using a memory profiler on the desktop. The NetBeans one works great and you can see memory growing without shrinking if you have a memory issue. You can track it down to a specific memory leak very easily.
I want to observe the dynamically allocated memory in a C program while running, and to detect memory leaks. My program allocates memory according to user input. I'm looking for hours now for tutorials that might help, but the thing is that all of what i've found is not based on user input! i want to insert input and run the "instruments" in the same time..any suggestions?
I'd suggest you watch WWDC 2012 video iOS App Performance: Memory. It gives excellent primer on types of memory, issues that can arise, coding conventions to watch out for, how to use Instruments to identify issues, etc. It's a good place to start.
Lots of leaks cannot be identified by the "Leaks" tool in Instruments. Check out the "Allocations" tool and some of the great features hidden in there such as heapshots (discussed in that video) or option-dragging in the Allocations tool graph. Also, make sure you avail yourself of the static analyzer ("Analyze" on the "Product" menu in Xcode, or command+shift+B) which can identify a remarkable number of issues just by analyzing at your code.
My C application on windows is running a for loop in which it dumps numerous entries into some data structure and then saves the same in an xml. Now, i want to know the memory footprint it is taking to do the same. Are there any tools available?
Task Manager is the way I do it. It's simple and easy.
But it only works if you're trying to measure very large memory footprints. But applications with large footprints are probably the only cases where you'd need to measure the usage anyway.
If you want to measure memory usage accurate to the byte, I would just build a simple wrapper around malloc() and free() that increments some global value. (if the app is threaded, a lock might also be needed)
Task Manager is one way to do it. I prefer Process Explorer because it gives a lot more info than Task Manager.
I need to prevent application's memory pages from being swapped out of RAM on Windows. Is there a WinAPI function equivalent of POSIX mlockall() to achieve that?
Yes, VirtualLock(). There's a limit on how many pages you can lock, you can't hog RAM. Details are in the MSDN article.
I have to ask, why do you need to do this? If every app thought its pages were so important that they shouldn't be paged out ever, it would be a giant waste of memory.
If the pages are in use, they won't be sent to the pagefile, and if they're not in use, why keep them around? Trust in Mm, it was written by a very smart guy :)
Hi you can set the windows option of lock pages in memory. Usually this setting is mostly used by SQL Server, but works also for other applications. Check this site on msdn
enable addressing windows extensions (AWE) for your application. See this link on msdn
I'm on Vista 64 and a blank 'WPF Application' template allocates 50MB when I press compile and run.
Surly this is way too much for an empty white box?!
Is there anything I can do to make my WPF applications less thirsty?
Jan
50 MB doesn't sound like that much for a modern application that makes heavy use of shared libraries.
Measuring memory usage is something of a black art. On some systems, apps which display the memory usage of a given app include in that total memory used by any shared libraries used by that app. But that memory is in fact being used by all apps using that library.
What is reporting the "50Mb" number to you? Task manager?
Generally speaking, I'd say that rather than worrying about unavoidable overhead for abstract use cases, it's better to develop your application and then analyze its memory usage in context to how it impacts performance.
Hope that helps.