[flexcoders] Re: Module GC question

2007-04-27 Thread kyle.vanvranken
To be honest I couldn't tell you why it was causing the issue. 

As for your problem, all the documentation I have seen on using the GC
"hack" says that it is just that a hack. You're not supposed to be
able to trigger GC and as such that it should only be used as a tool
in testing. My advice would be to step back for a min and find out
what is actually causing the memory leak you're having. At best the GC
hack would be a bandaid for the real issue at hand. I realize we all
have deadlines to make, but if your memory leak is that bad it would
seem to make sense that the greater good would be served by fixing
what is causing the leak.



[flexcoders] Re: Module GC question

2007-04-27 Thread kyle.vanvranken
Well as soon as I removed the call to force GC it started working. I
cant be sure, but logically it would make sense.



[flexcoders] Re: Module GC question

2007-04-27 Thread kyle.vanvranken
Think I misread your post the first time. As for being sure you can
see it unload the swf in console.

Documentation wise I've seen it a couple places. One of them being here:
http://www.gskinner.com/blog/archives/2006/08/as3_resource_ma_2.html
It's said that you should only use it in testing.

- Kyle



Re: [flexcoders] Re: Module GC question

2007-04-26 Thread jake247
Could you elaborate a bit more on why you think the GC hack was causing 
problems?  We're considering using it for a significant memory leak problem 
we're having ...

Thanks,

  -- Jeff Hindman

 "kyle.vanvranken" <[EMAIL PROTECTED]> wrote: 
> UPDATE: So it would seem the hack method of forcing garbage collection
> for my test was actually causing the trouble.
> 
> -
> try {
>   new LocalConnection().connect('foo');
>   new LocalConnection().connect('foo');
> } catch (e:*) {}
> -
> 
> Without that code it seems to be working nicely now. I've had a test
> app running on my machine now for a bit with a timer every couple
> seconds reloading the simple module and it appears to be working as
> intended now. I don't really understand why forcing GC was causing it
> to eat up more memory then not forcing, but I am sufficiently
> satisfied that it seems to be working.
> 



Re: [flexcoders] Re: Module GC question

2007-04-26 Thread Erik Price
On 4/26/07, kyle.vanvranken <[EMAIL PROTECTED]> wrote:
> UPDATE: So it would seem the hack method of forcing garbage collection
> for my test was actually causing the trouble.
>
> -
> try {
>   new LocalConnection().connect('foo');
>   new LocalConnection().connect('foo');
> } catch (e:*) {}
> -
>
> Without that code it seems to be working nicely now. I've had a test
> app running on my machine now for a bit with a timer every couple
> seconds reloading the simple module and it appears to be working as
> intended now. I don't really understand why forcing GC was causing it
> to eat up more memory then not forcing, but I am sufficiently
> satisfied that it seems to be working.

How are you sure that the hack was actually causing GC?  Is that
documented anywhere?

e


[flexcoders] Re: Module GC question

2007-04-26 Thread kyle.vanvranken
UPDATE: So it would seem the hack method of forcing garbage collection
for my test was actually causing the trouble.

-
try {
  new LocalConnection().connect('foo');
  new LocalConnection().connect('foo');
} catch (e:*) {}
-

Without that code it seems to be working nicely now. I've had a test
app running on my machine now for a bit with a timer every couple
seconds reloading the simple module and it appears to be working as
intended now. I don't really understand why forcing GC was causing it
to eat up more memory then not forcing, but I am sufficiently
satisfied that it seems to be working.



[flexcoders] Re: Module GC question

2007-04-25 Thread kyle.vanvranken
UPDATE:

It would seem I have the same memory problem even when using the
higher level ModuleLoader. I get the same results memory wise with my
system or the module loader. It still unloads the swf etc, but
continues to eat more and more memory.


http://www.adobe.com/2006/mxml";
layout="vertical" creationComplete="init()">













[flexcoders] Re: Module GC question

2007-04-25 Thread kyle.vanvranken
So I've been playing with ways trying to get the many module memory
issue cleared up and seem to be unable to get it to work in even a
very simple test case. Any chance you can tell me what I am doing
wrong here? When I force GC I can see the swf getting unloaded etc but
the memory use just keeps going up.

APP:

http://www.adobe.com/2006/mxml";
layout="vertical" creationComplete="init()">












CUSTOMLOADER: 

package com.widget
{
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import mx.modules.IModuleInfo;
import mx.modules.ModuleManager;
import flash.utils.Dictionary;
import mx.events.ModuleEvent;
import flash.display.DisplayObjectContainer;
import mx.utils.NameUtil;

public class CustomModLoader extends EventDispatcher
{
//REF TO ALL MODS
private var allMods : Dictionary;

public function CustomModLoader()
{
super();
allMods = new Dictionary(true);
}

public function loadMod(url : String, display :
DisplayObjectContainer, args : Array) : Object
{
//var module : IModuleInfo = 
ModuleManager.getModule(url);
var uniName : Object = 
NameUtil.createUniqueName('Widget');
allMods[uniName] = new Array();
(allMods[uniName] as Array)['info'] = 
ModuleManager.getModule(url)
as IModuleInfo;
//module.addEventListener(ModuleEvent.READY, modReady);
   // module.addEventListener(ModuleEvent.ERROR, modError);
(allMods[uniName] as
Array)['info'].addEventListener(ModuleEvent.READY, modReady);
(allMods[uniName] as
Array)['info'].addEventListener(ModuleEvent.ERROR, modError);

function modReady(e : ModuleEvent) : void
{
(allMods[uniName] as
Array)['info'].removeEventListener(ModuleEvent.READY, modReady);
(allMods[uniName] as
Array)['info'].removeEventListener(ModuleEvent.ERROR, modError);
//module.removeEventListener(ModuleEvent.READY, 
modReady);
//module.removeEventListener(ModuleEvent.ERROR, 
modError);
trace(uniName + " - READY");

(allMods[uniName] as Array)['mod'] = ( (allMods[uniName]
as Array)['info'] as IModuleInfo ).factory.create() as IWidgetMod;
//var widget : IWidgetMod = module.factory.create() as
IWidgetMod;
( (allMods[uniName] as Array)['mod'] as IWidgetMod
).init(display, args);
uniName = null;
//widget.init(display, args);
//allMods[uniName] = {mod: widget, 
info: module};
/*
widget = null;
module = null;
uniName = null;
*/
}   

function modError(e : ModuleEvent) : void
{
trace("error loading module " + e.module.url);
  (allMods[uniName] as
Array)['info'].removeEventListener(ModuleEvent.READY, modReady);
  (allMods[uniName] as
Array)['info'].removeEventListener(ModuleEvent.ERROR, modError);
  uniName = null;
}
   (  (allMods[uniName] as Array)['info'] as IModuleInfo ).load();
//module.load();
return uniName;

}

public function killMod(name : Object) : void
{
if(allMods[name] != null)
{
( (allMods[name] as Array)['mod'] as IWidgetMod 
).destroy();
( (allMods[name] as Array)['info'] as 
IModuleInfo ).release();
( (allMods[name] as Array)['info'] as 
IModuleInfo ).unload();
 (allMods[name] as Array)['mod']  = null;
(allMods[name] as Array)['info']  = null;
allMods[name] =null;
delete allMods[name];
} else
{
trace("NO MOD!");
}


/*
if(allMods[na

RE: [flexcoders] Re: Module GC question

2007-04-20 Thread Alex Harui
When you call unload on a ModuleInfo, you are just releasing one
reference to it.  There's no practical way for us to keep track of all
references to things in a module and go clean them up.  However, while I
suppose it is the "safe" approach to clean everything, you might be
better served knowing what things to clean.  It makes it clearer what
the connections are between modules and forces you to have a cleaner
architecture in order to minimize the number of connection points.
 
Note also that event listeners are "backwards".
someObj.addEventListener("event", myEvent) doesn't make an additional
reference to someObj, it makes a reference from someObj to the owner of
myEvent.
 
-Alex



From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of kyle.vanvranken
Sent: Thursday, April 19, 2007 8:26 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Module GC question



So it would be best to remove all listeners that you can and set every
var the module is using to null before unloading it to get that memory
back.

That's definitely doable I'm just surprised that unloading the module
doesn't wipe out all those references. Thanks for the quick reply Alex!



 


[flexcoders] Re: Module GC question

2007-04-19 Thread kyle.vanvranken
So it would be best to remove all listeners that you can and set every
var the module is using to null before unloading it to get that memory
back.

That's definitely doable I'm just surprised that unloading the module
doesn't wipe out all those references. Thanks for the quick reply Alex!



[flexcoders] Re: Module GC question

2007-04-19 Thread kyle.vanvranken
I found a really good series of articles further explaining my issue.
On the off chance anyone has a similar issue here they are.

http://www.gskinner.com/blog/archives/2006/06/as3_resource_ma.html
http://www.gskinner.com/blog/archives/2006/07/as3_resource_ma_1.html
http://www.gskinner.com/blog/archives/2006/08/as3_resource_ma_2.html

Specifically the one pertaining to my issue is:
http://www.gskinner.com/blog/archives/2006/07/as3_resource_ma_1.html