Author Topic: Memory Management - Release memory  (Read 909 times)

globule22

  • Jr. Member
  • **
  • Posts: 40
Memory Management - Release memory
« on: April 02, 2010, 08:48:39 am »
Hi,

I am faced to a memory issue with my book cointaining 3D panoramas. (www.regionalesbretagneenimages.fr)

With my project book, around 100 double pages, without panoramas, i stay around 90Mo when i read all the book, the memory management in Megazine works well, it destroy the page not visible after 1 or two page turn.

But when i simply add just one panorama for debugging, whaaaooo.
I start at 90Mo, and when i watch the panorama page, i jump to 145Mo, ok, understandable.

I have modify my panorama Loader to destroy all the objects referencing to the panorama, when i jump to the next page, but i stay after around 140Mo, and around this value if i finish the book with all simple pages.

So for me, the best solution is to destroy all the elements on the megazine page.
I have checked that object PageSide have a special function unload, which can be force to true, unload(true), but at the end of it, it reload the elements of the page, so i have use a duplication of this command, unloadSimple which doesn't reload the page, but the elements in memory are already here.

So, did the garbage collector works well with this method?

Thanks



globule22

  • Jr. Member
  • **
  • Posts: 40
Re: Memory Management - Release memory
« Reply #1 on: April 02, 2010, 11:32:04 am »
Ok, first solution found, adding System.gc(); perform a good garbage collector release.

But now my goal is:

When page is not visible to remove the img object, destroy it, and when the page was reopened, readd the img object.

Any idea?
« Last Edit: April 02, 2010, 02:53:20 pm by globule22 »

Florian Nücke

  • κρύα πόδια
  • Administrator
  • Hero Member
  • *****
  • Posts: 1989
  • MegaZine3 Developer
    • MegaZine3
Re: Memory Management - Release memory
« Reply #2 on: April 04, 2010, 04:52:01 pm »
The simplest approach would be to just set the book@maxloaded attribute to 2 (to only keep 2 pages loaded at any given time).
Alternatively, try using the megazineSetup function to register for page visibility events (see the code snippets article in the wiki).
For the Snark was a Boojum, you see.

Before you ask a question
          After you get an answer
  • please document your problem with the answer in the Project Wiki. (e.g. in the FAQs)
  • help others out if you can, by answering their questions on the forum.

globule22

  • Jr. Member
  • **
  • Posts: 40
Re: Memory Management - Release memory
« Reply #3 on: April 04, 2010, 07:03:25 pm »
Thanks for your reply.

I have the megazinesetup function in my panorama loader to handle page visibility. No problem for that. My problem is after when the page is no longer visible, and the objects of my panorama player kept in memory.
I have try several methods and it seems when i call several times System.gc() to force garbage collector, i release some memory.

My problem is always here if i discharge all my objects in my panorama loader. It seems that all the memory part taken by my swf is the same than the img object of Megazine created for displaying this swf.

So i have tried to call the function unload in pageside when my swf is no longer visible, this function call the unloadIternal function in pageside, and after this one call the unload function in each elementproxy object,and in the destroy function of element object it called destroy function, but no effect, if i put System.gc() in each function, the trace function in my swf are always called when the page becomes visible after.

So my question is:
Is it possible to really destroy the img object containing my swf, and when my page rebecomes visible, to reload all the elements of the page, and so my swf?

I achieve a little that two days ago (on another computer with Flash 9 code, and i don't achive to recode that here in Flash 10 on my personal computer), but when the page rebecomes visible, and when i call the load function, no effect... :-[