Open barisyild opened 6 days ago
var completedJobs = 0; lime.app.Future.FutureWork.maxThreads = 16; var bitmapData:BitmapData = new BitmapData(1920, 1080); var imageByte:Bytes = bitmapData.encode(bitmapData.rect, new PNGEncoderOptions()); var images:Array<Image> = []; function createFuture():Future<Dynamic> { trace("createFuture"); return Image.loadFromBytes(imageByte).onComplete(image -> { completedJobs++; images.push(image); if(images.length > 4) { //images.shift(); images = []; openfl.system.System.gc(); } createFuture(); }); } for(i in 0...16) { createFuture(); } openfl.Lib.setInterval(() -> { trace(lime.app.Future.FutureWork.activeJobs); trace(completedJobs); // Allocate 1-10MB of memory Bytes.alloc(1024 * 1024 * (1 + Std.int(Math.random() * 10))); }, 0);