magic number inside the WWW class? can't load after 5000+

I am working on an application that need to load thousands of small textures (256x256 pixel) in runtime (aka map engine :p). I found that each time, I loaded the texture around 5849 times or near, the system will stop and crash ! Anyone have an idea of that ?

following is the dummy script for that issue.
(WARNING: This script may crash the OS too. Remember QUIT Unity immediately when its stopped !!!)

var g:GameObject;

var frame:int = 0;
var busy:String = "loaded";

var time_to_dead:int = 0;  // Magic Number 5849 !?!?!

function Start () 
{
	g = new GameObject.CreatePrimitive(PrimitiveType.Plane); 
}

function Update () 
{
	if (busy == "loaded") { busy = "loading"; test(); time_to_dead++; }
}

function test()
{
	var www: WWW;
	var _temp:Texture;
	
	www = new WWW("http://127.0.0.1/~antonioh/loading_jpg/"+frame+".jpg");
	
	yield www;
	
	_temp = g.renderer.material.GetTexture("_MainTex");	
	g.renderer.material.mainTexture = [url]www.texture;[/url]
		
	yield WaitForSeconds(0.025);
	if(_temp) { Destroy(_temp); }
	www.Dispose();
	www = null;
	
	frame = (frame+1)%1024;
	busy = "loaded";
}

I tried, using with/without “Destroy()”, the issue is the same, except, its got faster to crash when not using Destroy. The “WaitForSeconds()” make no different. I also, run that on other machine with less memory installed and got 6100+ ??!?!

Many Thanks,
Antonio Hui

I hesitate to say that this is a WWW problem, but rather related to the thousands of textures you’re trying to load in, and perhaps your method of storing/deleting them.

Thanks for your reply, Tempest,

I am not sure too.

In the real application, I built some arrays with time-stamp… buffers… etc to hold the reference of textures. The loading and killing cycle are work fine for few hours until its reach that amount of textures.

Antonio

check the process manager and see if you run out of RAM and in unity show the stats to see if you run out of vram.

highly doubt there is a magic number where it just stops working, more like a magic number where you overload the available memory / graphics memory

Hi Dreamora, thanks for your trips.

Well, but everything seem to be fine :stuck_out_tongue:

(the RSIZE raised from 82MB before click the play button)

Antonio

is that at the beginning?
Or after you let it run for over an hour to achieve the 5xxx loads? (the runtime is the important thing here because otherwise the issue might not be the WWW class but that you flood the server and it decides that you shall go to hell with your flood :wink: )

the above screen cap is taken when the script is running (right before the stopping :slight_smile: since, I do know when it will stop, almost at the same number :stuck_out_tongue:

PS. I try to do another test by move all texture onto a real web site.
will update the result when I done.

www = new WWW("http://homepage.mac.com/antonioh/dev/loading_jpg/"+frame+".jpg");

Many Thanks,
Antonio

hi dreamora, you are right. that don’t seem to the problem of www directly.

I found that the mentioned issue are…

Editor ( OSX10.5.8 ) —> FAIL around 5000+
Standalone ( OSX10.5.8 ) —> FAIL same as Editor
Standalone ( WinXp Sp4 ) —> FAIL around 4000+
WebPlayer ( WinXp, FireFox 3.5 ) — > PASS
WebPlayer ( MAC, Safari 4 ) —> PASS
WebPlayer ( MAC, FireFox 3 ) —> PASS

The mac version of WebPlayer with Safari 4 can handle around 50,000+ calls, until in cause memory overflow at 2GB. The pc version of WebPlayer are still running beyond 100,000+ calls now :slight_smile:

Since the application will be used for web mainly, I guess, I can handle the rest of issue.

Many Thanks to All :slight_smile:
Antonio Hui

PS. The memory usage with FireFox(Mac/PC) did not raised up too :slight_smile: