Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory leak on windows phone 8

I am developing a windows 8 Native App. My app is getting crash after going back and forth in the application for sometime. On Analysis, using the memory profiler i found that each time i navigate from one page to another the memory usage increases inspite of me setting null all the objects of list, webclient, string and so on to null and calling GC.Collect after that on the NavigatedFrom Event.

Firstly i thought it would be due to the images and hence i removed the images from the app and tested but still there is no change in the memory usage of the app. Somehow the GC.Collect isn't working and freeing the memory.

I have tried the below mentioned things but to my bad luck isnt working to release the memory, instead the result remains the same.

  • I have set the image urisource to null before setting the new source and then call gc.Collect to free the memory usage but it does not seem to release it

  • Secondly , I have set all the objects to null, and call GC.Collect() but still it does not free up the space from the memory usage of the phone app.

  • I also tried to analyze using the memory profiler but I am not able to track anything.

I have also gone through all the post and implemented the suggested things but the GC.Collect() doesnt seem to release the memory.

Is there any work around for the following issue.How can i free the memory consumed on navigating from one page to another?

like image 475
user2728319 Avatar asked Aug 29 '13 08:08

user2728319


People also ask

How do I find out what is causing my memory leak?

One way to check for memory leak is to press and hold down your Windows key and tap the Pause/Break key to bring up System Properties. Click on the Performance tab and check System Resources for the percentage of free or available RAM.

How do I find a memory leak in Windows?

Find a Memory Leak With Windows' Resource MonitorPress Windows key+R, enter "resmon," then select OK. Select the Memory tab, then select Commit to reorder the list. Monitor the Standby (blue bar) with the applications with the applications you usually use running.

Is memory leak serious?

A memory leak is one of the major causes of the slowing down of a computer. It can be dangerous and lead to serious system stability issues.


1 Answers

Seems like something is preventing the objects from being recycled by the garbage collector in some cycle. This could be, and normally is, due to some events handlers not being removed, thus mantaining the object alive.

If you have any event in the page or the viewmodel, or any object within the page, remove it (-=) in the onNavigatedFrom method prior to exit the page... This maybe do the trick and your page memory is free....

like image 126
Josue Yeray Avatar answered Oct 18 '22 21:10

Josue Yeray