Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future freezing application #1864

Open
barisyild opened this issue Nov 16, 2024 · 0 comments
Open

Future freezing application #1864

barisyild opened this issue Nov 16, 2024 · 0 comments

Comments

@barisyild
Copy link
Contributor

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);

image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant