locked
WPF Page stays in memory RRS feed

  • Question

  • i have wpf application with Frame, and some predefined Pages, i added some code to monitoring whether Page created and destroyed. I don't need any history, so i immediately clear it after navigate to another Page. What i see? Pages created and destroyed. But one of the pages only created and never destroyed... and i don't understand why? all of my pages don't have any special logic.


    After some researching, i've found that when i call Frame.Navigate to another page, WebBrowser component of my page (with memory problem) also calls his own Navigate method...why? maybe here is the problem that prevent memory collector to destroy that page?


    if it needs, i can provide some code later. 



    • Edited by VenSP Thursday, March 15, 2012 5:37 AM
    Wednesday, March 14, 2012 1:04 PM

Answers

  • ok, solved the problem.


    Again, after some researching, i've found, that problem appears when i define event handlers on WebBrowser events. I've used System.Windows.Forms.WebBrowser (used it for suppress script errors), i changed WebBrowser to System.Windows.Controls.WebBrowser. Again, defined new event handlers and....


    After call Frame.Navigate(), WebBrowser don't called his Navigate and page no longer remain in the memory.

    • Proposed as answer by SharpAspirant Friday, March 16, 2012 8:13 AM
    • Marked as answer by Sheldon _Xiao Wednesday, March 28, 2012 9:30 AM
    Thursday, March 15, 2012 6:38 AM

All replies

  • ok, solved the problem.


    Again, after some researching, i've found, that problem appears when i define event handlers on WebBrowser events. I've used System.Windows.Forms.WebBrowser (used it for suppress script errors), i changed WebBrowser to System.Windows.Controls.WebBrowser. Again, defined new event handlers and....


    After call Frame.Navigate(), WebBrowser don't called his Navigate and page no longer remain in the memory.

    • Proposed as answer by SharpAspirant Friday, March 16, 2012 8:13 AM
    • Marked as answer by Sheldon _Xiao Wednesday, March 28, 2012 9:30 AM
    Thursday, March 15, 2012 6:38 AM
  • Hi VenSP,

    Glad to hear you have resolved it by yourself, if you have got what you need, could I close your thread as "Answered".

    Best regards,


    Sheldon _Xiao[MSFT]
    MSDN Community Support | Feedback to us
    Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, March 16, 2012 8:00 AM