How To make certain that a page is removed from memory, silverlight


Hello,
I have a big solution with several branches. These branches was tested individually for errors and memory issues, using VS profiler and debugger. A final solution was found that at highest with animations and music peaked to 100mb, of course high but should
not be an issue for Windows phone applications, even for low end devices. The branches was then collected to one main branch. A new test was run, and suddenly the memory spiked up towards 200mb and crashed on phones and emulators with out of memory exception.
We at the team then tried:
protected override void OnNavigatedTo(NavigationEventArgs e)
if (App.RootFrame.CanGoBack)
App.RootFrame.RemoveBackEntry();
GC.Collect();
base.OnNavigatedTo(e);
This was discussed on forums to help with page memory leakage, this however did not solve the issue. We therefore wanted to investigate if pages and other elements got deconstructed and GC.Collected. This we did by implementing deconstructors:
~SecondScreen()
In_Game_Crest = null;
currentViewModel = null;
This confirmed our fears that the pages, popups and controls did not get garbage collected, even if we sat everything to null, or
set everything to private functions. Our code is implemented in a MVVM structure, we therefore looked to ViewModelLocator, and removed the servicelocator, as to force a new viewmodel creation for every page creation.
This showed that the viewmodels got garbage collected upon navigation, but the views and usercontrols did not. We therefore searched around for the issue and found some links that could help us, referring to IDisposable, we therefore tried with the following
implementation:
private bool disposed = false;
public void Dispose()
Dispose(true);
// Take yourself off the Finalization queue
// to prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
protected virtual void Dispose(bool disposing)
// Check to see if Dispose has already been called.
if(!this.disposed)
// If disposing equals true, dispose all managed
// and unmanaged resources.
if(disposing)
// Dispose managed resources.
currentView = null;
popup = null;
Image1 = null;
Image2 = null;
// Release unmanaged resources. If disposing is false,
// only the following code is executed.
this.Content = null;
// Note that this is not thread safe.
// Another thread could start disposing the object
// after the managed resources are disposed,
// but before the disposed flag is set to true.
// If thread safety is necessary, it must be
// implemented by the client.
disposed = true;
// Use C# destructor syntax for finalization code.
// This destructor will run only if the Dispose method
// does not get called.
// It gives your base class the opportunity to finalize.
// Do not provide destructors in types derived from this class.
~FirstPage()
Dispose(false);
protected override void OnNavigatedFrom(NavigationEventArgs e)
this.Dispose();
base.OnNavigatedFrom(e);
This however only increased the memory usage by 20 mb, for every call to dispose. Which hopefully would mean that we have misunderstood the use of IDisposable.
Questions:
Therefore quite confused, I have learned from my similar question on Stackoverflow, that I should use the VS profiler more intently to find references, but I have not succeeded in finding anything with the profiler. And I do not understand why the
deconstructors are not fired when I know no references exists.
Therefore would it help to implement IDisposable and how should it be done in a windows phone Silverlight context?
Should I do something specific when I utilize the MVVM structure?Any proposals on how to force the deletion and how to do the deletion correctly?
Or is there some other way to go about it, to ensure that pages with all information is removed.
Hope for any help, If you want stackoverflow points I also have the following: stackoverflow.com/questions/27744091/implementing-dispose-and-finalize-for-windows-phone-silverlight-pages/

One way i can suggest is to use 'Using' statement(obviously if not already did that) wherever it is required to work with resources such as opening a connection to database, file operations etc. With this, the resources are disposed automatically as soon
as 'Using' block goes out of scope.
e.g.
using (StreamReader reader = new StreamReader("somefile.txt"))
your code
http://developer.nokia.com/community/wiki/Using_Crypto%2B%2B_library_with_Windows_Phone_8

Similar Messages

  • How to Make a Printable Results Page in Adobe Captivate 8

    Hi Captivate Developers!
    We made a really cool Captivate tip that I think you will enjoy. This tip allows your learners print-friendly results in Adobe Captivate 8. We also include the code needed to make it work and is actually pretty easy. It also includes videos for each step. Hope you like it!
    http://elearningbrothers.com/how-to-make-a-printable-results-page-in-adobe-captivate-8/

    If you have a dynamic web site (database driven), use PHP or ASP data queries.
    If your site is static (no databases), look at the links below:
    Zoom Search Engine software
    http://www.wrensoft.com/zoom/index.html
    Free Find
    http://www.freefind.com/
    Pico Search
    http://www.picosearch.com/
    Google Site Search -
    http://www.google.com/sitesearch/
    Web Assist DW Tools for Google (free)
    http://www.webassist.com/free-downloads/dreamweaver-extensions/dreamweaver-tools-for-googl e/
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists 
    http://alt-web.com/
    http://twitter.com/altweb

  • HT4515 How to make sure that after browsing that the webpage is not running in the background, but totally closed down

    How to make sure that after browsing that the webpage is not running in the background, but totally closed down

    Double tap the Home button, tap & hold the Safari icon until it starts to wiggle, tap the red minus sign to remove it from the Multi-Tasking bar. Tap the Home button when finished.

  • How to make table that will include controls such as drop list?

    How to make table that will include controls such as drop list?
    I need to create table as Property Browser of ActiveX, that include rows with differnt types such as drop list, color, ...

    Hi Nadav,
    I figured out where I missed your point. When you wrote
    table as Property Browser of ActiveX, that include rows with differnt types such as drop list, color, ...
    I was thinking mixed data-types in a [2d] table!
    Looking at the property browser again it looks like no single LV function can do all of that. It can be developed as a pop-up (like the browser is set-up) and then code all of the elegance using an event structure to control the background color of a string indicator while controling the visability of rings that are only made visable when a mouse down is detected. That will get you pretty close.
    So no, my previous response ws not correct for what you are trying to do if you want to duplicate all of the wistles and bells of the property browser pop-up window.
    Please forgive my distraction.
    Ben 
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • How to make sure that schema name is not included with generated sqls

    How to make sure that schema name is not included with generated sqls with tableadapter wizard.
    What should I use? Oledb, ODT.NET, where can set that I want "pure" sqls, not schemas, not ", or anything like this
    I want
    "Select a,b from t1" ,not "select "a","b" from schema.t1"
    Also schema name is put in all parameters, all over the place... What if schema name changes. (b1test to b1prod)
    . I now manually edit XML files of dataset. It works but....
    thanks

    The full hardware :
    Processor Intel core due 3.00 MHz
    RAM:1.5GB
    psu:650 Watt (but i baught i cheap one so it may be actually about 400 watt)
    HD Disk:160 GB
    But about the power supply if it not able to run the VGA card ,Is it will not show any screen or it will not able to run the computer??

  • How can i find that which page is opened in other browser window

    How can i find that which page is opened in other browser window
    Can i restrict opening of a new instance of browser by end user.
    Thanks in advance.

    you can use Javascript functions/varibles.
    In any page you can insert a special form like this:
    <form name="myNameWindow">
    <input type="hidden" name="myName" value="Ivan_pag01">
    </form>
    and in the other reading that value.
    Obviusly you have to save a reference in a variable of the other window.
    This is possible only if:
    1) other page is in the same browser window but in an other frame
    2) you have generated the other page via an "window.open" function (or your page is generated from it via that function)
    -- Ivan

  • TS4209 Is there a way to make certain that I have this update? I run software update, and nothing is available, yet the problem persists.

    Is there a way to make certain that I have this update? I run software update, and nothing is available, yet the problem persists.

    I added this post in response to this parent post: http://support.apple.com/kb/TS4209?viewlocale=en_US&locale=en_US
    The parent posts mentions the solution to my problem is the update available when you run software update. However my system is up to date, and I still have the problem.
    Further information:
    When I return home from work, and wake my computer, the Wi-Fi indicator shows that it is trying to connect. It fails, and the signal bars show zero connectivity. If I click on the Wi-Fi indicator, the computer then searches for nearby networks, and I am able to select mine. Then it connects.
    It seems very clear that the problem is my iMac tries to connect before looking for networks.

  • How to make compressor give me 1280x720   h.264 from my 1440 x 1080 sequenc

    can someone please tell me how to make compressor give me 1280x720 h.264 from my 1440 x 1080 sequence, with compressor I load up my high defition h.264 but i cant see where i can chage the size, I can tab on the preset and change max bit rates and other stuff but not to make it 1280 x 720,
    Thanks for the help,
    Daz

    In Compressor 3's Settings window:
    Apple > Apple Devices > H.264 for Apple TV
    this is one of the presets that is supplied as standard and it is pre-configured for H.264 1280x720 output
    if you're building your preset from scratch then you can set the output frame size in the Dimensions area of the Geometry pane

  • How can I remove apps that I downloaded and removed from "purchased" at App Store?

    How can I remove some apps that I downloaded and removed from "purchased" list at App Store??
    Thanks Vic

    You can't remove apps from the purchased list. It's impossible. You can hide them but not delete them from the purchased list.
    Tap and hold down on the app icon until it wiggles then tap the X on the icon to delete it, tap the home button to stop apps from wiggling.

  • I set up my iPhone through iCloud but assigned the wrong cell number to it so I am getting messages that don't belong to me but rather to my husband as I entered his cell number in there - how do I change that number to stop this from happening??

    I set up my iPhone through iCloud but assigned the wrong cell number to it so I am getting messages that don't belong to me but rather to my husband as I entered his cell number in there - how do I change that number to stop this from happening??

    Also, if you are sharing an Apple ID, you will get his iMessages.

  • How do u know that your zen micro suffer from headjack proble

    I went to change my black zen micro on 7/6/2005 (b'cos of headjack problem) and again i think it happening again...awh :angry: i didnt really used my mp3 and i didnt really know how it suffer from this probelm,
    .What are the effects or How do you know that your zen micro suffer from headjack problem ?
    2.Can we change colour when we sent the Zen micro to repair ?
    awh somebody help mi...

    you know u've been hit with the headphone jack problem when the music channels out of the left and right ears and if you wiggle your jack (depending on which way) you music will fade in and out and become distorted, its happened to me twice already, although my new micro seems much more firm thent he last three.

  • How do I re-add a device I removed from Find My Iphone?

    How do I re-add a device I removed from Find My Iphone? I decided I did not want to lock it remotely in case it is located.

    same way you added it the first time
    https://www.google.dk/search?source=ig&rlz=1G1TSEH_ENDK367&q=add+a+iphone+to+fin d+my+iphone&oq=add+a+iphone+to+find+my&gs_l=igoogle.3.0.0i19j0i5i19j0i8i30i19.91 64420.9174320.0.9175191.37.30.7.0.0.0.235.3180.17j9j2.28.0...0.0...1ac.1.4IPvfNe pj_s

  • How to make it that when i click my logo, it goes to the home page?

    I want to make it on my website, that when i click on my logo on the top of my webpages, it should go to the home page. How can I do that?
    My website is www.iphoneappguru.com
    Thanks!
    -RahulR

    Select the logo in iWeb and use the Inspector/Link/Hyperlink pane to link the logo image to "One of my pages"
    Click to view full size
    However, I would not use the First menu option but select the page name instead.
    OT

  • How to make my dynamic form pages flow correctly?

    I have created a dynamic form which has multiple questions with expandable text fields that will take multiple pages once completed.  I do not know how to make the form flow correctly past the first page.  I can attach the form if I knew how to do that.

    Thank you Paul.  Your editing assistance was greatly appreciated. I think I now understand that there should be only one page subform that is flowed, regardless of how many text box objects I have in my questionnaire. This did the trick.

  • How To Make Void That Prints Something In JSP

    hi Everyone I'm Very New To Java & JSP I'm Expert In PHP , Anyway . .
    I want A Code like The Following Print Something Out :
    <%@ page import = "java.io.*"%>
    <%!
    public void str_repeat(String str2,int num){
         int i;String FINAL="";
         for(i=0;i<num;i++)FINAL=FINAL+str2;
         System.out.print(FINAL);
    %>
    <%
    str_repeat("SOMETHING",2);
    %>And Please I don't Want Anyone to Come UP with A Function That Makes The String Repeat (( I Wan To Learn How To Make A Void That Outputs Something )) And Not A Function . .
    notice : The Above Code Gives Nothing At All And When I Use
    out.print Instead Of System.out.print It Gives Error

    My Code Now Is As Follows :
    <%@ page import = "java.io.*"%>
    <%!
    public void str_repeat(String str2,int num, JspWriter out){
         int i;String FINAL="";
         for(i=0;i<num;i++)FINAL=FINAL+str2;
          out.print(FINAL);
    %>
    <%
    str_repeat("SOMETHING",2, out);
    %> and it gives the following error :
    org.apache.jasper.JasperException: Unable to compile class for JSP:
    An error occurred at line: 17 in the jsp file: /index.jsp
    Unhandled exception type IOException
    14: public void str_repeat(String str2,int num, JspWriter out){
    15:      int i;String FINAL="";
    16:      for(i=0;i<num;i++)FINAL=FINAL+str2;
    17:       out.print(FINAL);
    18: }

Maybe you are looking for

  • Power Mac Dual 2.5 G5 won't start up!

    Downloaded Mac OS X Server 10.4.8 Build 8L117 {Power PC} for testing purposes and the installer upgraded my system. Upon restart, I get the progress bar loading all the way but then just stops and does nothing - won't go to the login window. I have n

  • Icons on navigation panel

    HI Everyone, If anyone know how we can configure to get icons on dynamic navigation panel. I appreciate if any can help. Thanks, Vinay

  • Conky is cut off with scrotwm

    Problem is rather self explanatory, conky displays all of the code in tty1 but is cut off before finishing in scrotwm. I have played around with minimum_size and maximum_width a lot without success. However, that did fix the same problem on my netboo

  • Preferences error - could not load displays preference pane

    My screen resolution changed during game play. Now that the game is off, I cant change it back. This is what the error message says "Preferences Error - Could not load Displays preference pane."

  • Update TIN numbers for BP Customer and Vendor Records

    Hi experts Needed to update the TIN numbers for existing vendors and customers in SAP B1,please let me know the  templates and necessary field to update the same Regards Srinivasan