Issue 238: Benchmark Crash
Status:  New
Owner: ----
Reported by ncanna...@gmail.com, Apr 25, 2013
While running some benchmarks on HxCPP I have managed to crash the application by doing the following :

class Test {

	static var t0 = getTime();

	static function getTime() {
		return haxe.Timer.stamp();
	}
	
	static function time(where,?pos) {
		var dt = getTime() - t0;
		haxe.Log.trace(where+" "+dt,pos);
		t0 = getTime();
	}

	static function main() {
		var count = 1000000;
	
		time("Startup");
			
		var a = [];
		for( i in 0...count ) {
			var m = new h3d.Matrix();
			m.identity();
			m._41 = i;
			a.push(m);
		}
		
		time("Allocation");

		a = [];
		for( i in 0...count ) {
			var m = new h3d.Matrix();
			m.identity();
			m._41 = i;
			a.push(m);
		}
		
		time("Allocation2");
	}

	
}
Apr 25, 2013
Project Member #1 gameh...@gmail.com
This seems to work ok on my windows box - even with 10x the number of matrices.  You are asking for 128M of matrix data, which might stress a mobile device.
Do you have any kind of stack trace - eg, if malloc is returning null?
I thought it would be pointless to throw an exception here, since there might not be enough memory to process the result.  Maybe I could hold a small amount back for this purpose.
Generally, the GC is designed to work with a smaller active object footprint and it fights hard before increasing this memory footprint.  If you typically wanted to allocate so many floats in objects (not in arrays) then there is some tuning that could be done to the GC.