Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flash wastes memory with loadvars

Status
Not open for further replies.

Tiansen

Programmer
Dec 14, 2005
13
0
0
SI
Okay, here is a sample, that wastes memory. It reads variables from server (database) continuosly (onLoad is called when previous loading is complete). Memory usage grows every minute, so it is unusable.

load_lv=new LoadVars();

load_lv.load("/path/to/php/file.php");

load_lv.onLoad=function(success:Boolean)
{
if(success)
{
load_lv.load("/path/to/php/file.php");
}
}


Why is this simple sample wasting memory? Does someone know how to rewrite it to resolve this issue?
 
Instead of loading the same variable and going into an infinete loop (no wonder memory usage goes up!), do something useful upon loading.

[tt]//
load_lv=new LoadVars();
load_lv.load("/path/to/php/file.php");
load_lv.onLoad=function(success:Boolean)
{
if(success)
{
trace(this.toString())
//Do something useful with it
}
else
{
trace("Couldn't load it!")
}
}
//[/tt]

Kenneth Kawamoto
 
Well, I must react to some change in database. Any approach that notifies me when something is changed in a database (MySQL) would do. I just don't remember any other way right now.
 
Even that is leaking memory!

this.createTextField("mytxt", 100, 0, 0, 100, 20);
mytxt.autoSize = "left";

load_lv=new LoadVars();

setInterval(readdata,500);
function readdata()
{
load_lv.load("}
 
My previous post was not so clean. Here we go again:

But... even that is leaking memory! Although not so fast as before but still way too much!

load_lv=new LoadVars();

setInterval(readdata,500);
function readdata()
{
load_lv.load("/path/to/file.php");
}
 
I must be notified about change in a database as soon as possible! I'm a little disappointed about Flash behaviour in that matter. There must be some way around that. No matter if I set interval to 5000 or 500, memory leak will grow, faster or slower. It's just not ok. Something is wrong with script or with flash design. I just don't know what...

P.S.: Can Flash Remoting help here?
 
I think Flash Communication Server has been renamed to Flash Media Server.
 
So I must have a separate license of Media Server for each application I make with that. That's more than 2000 euro pro application. Way too much.... :(
 
I am now using Macromedia Flash 8 Trial Version. If I can resolve this memory issue I will buy at least one Flash license. Because I am a trial user now, I cannot post directly to Macromedia. Can someone that has a registered product post the following to Macromedia ( and give me an answer please:

I cannot figure out what is causing this example to slowly leak a memory. I've also tried some variations including use of "delete", but it also didn't help. Another issue is that it works under Mozilla Firefox (where it leaks memory), but it doesn't work under Internet Explorer (it doesn't refresh load_lv).

this.createTextField("mytxt", 100, 0, 0, 100, 20);
mytxt.autoSize = "left";
load_lv=new LoadVars();

load_lv.load("variables.php");
setInterval(readdata,1000);

function readdata()
{
if(load_lv.loaded==true)
{
load_lv.load("spremen2.php");
mytxt.text=load_lv.test;
trace("Successfully loaded!");
}
else trace("Not loaded yet!");
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top