{"id":582,"date":"2017-03-23T17:05:18","date_gmt":"2017-03-23T17:05:18","guid":{"rendered":"https:\/\/ibex.tech\/windows-iot\/?p=582"},"modified":"2017-03-23T17:05:18","modified_gmt":"2017-03-23T17:05:18","slug":"memory-leaks","status":"publish","type":"post","link":"https:\/\/ibex.tech\/csharp\/uwp-programming-in-c\/troubleshooting\/memory-leaks","title":{"rendered":"Memory Leaks"},"content":{"rendered":"<p>\n\tC# apps are perfectly susceptible to memory leaks. They are different to old unmanaged C++ memory leaks, but they still happen and can be just as hard if not harder sometimes to find. &nbsp;Instead of memory leaking and becoming lost to the system, in C# you can have memory the garbage collector running in the background never decides to release back to the OS because it thinks its still needed.\n<\/p>\n<h4>\n\tObjects that need disposing<br \/>\n<\/h4>\n<p>\n\tDispose Dispose Dispose! &nbsp; If you&#039;ve created and object and will then never need it again .dispose() of it.\n<\/p>\n<p>\n\tSeach your project for &quot;= null;&quot; and if you are setting an object to null after use check to see if you can call &quot;.Dispose()&quot; first.\n<\/p>\n<h4>\n\tEvent Handlers subscribed to objects<br \/>\n<\/h4>\n<p>\n\tOne common mistake is to not remove event handlers that subscribe to an object. An event handler subscription will prevent an object from being recycled.\n<\/p>\n<p>\n\tEven if you are not assigning event handlers, do any methods you call and pass objects to do it to acomplish what they need to acheive?\n<\/p>\n<h4>\n\tiDisposable<br \/>\n<\/h4>\n<p>\n\tWrap objects that implement IDisposable in &quot;using()&quot; blocks? &nbsp;\n<\/p>\n<p>\n\t&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>C# apps are perfectly susceptible to memory leaks. They are different to old unmanaged C++ memory leaks, but they still happen and can be just as hard if not harder sometimes to find. &nbsp;Instead of memory leaking and becoming lost to the system, in C# you can have memory the garbage collector running in the [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[72],"tags":[],"class_list":["post-582","post","type-post","status-publish","format-standard","hentry","category-troubleshooting"],"_links":{"self":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/comments?post=582"}],"version-history":[{"count":0,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/posts\/582\/revisions"}],"wp:attachment":[{"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/media?parent=582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/categories?post=582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ibex.tech\/csharp\/wp-json\/wp\/v2\/tags?post=582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}