Object Pool module

About Monkey 2 Forums Monkey 2 Code Library Object Pool module

This topic contains 3 replies, has 3 voices, and was last updated by  regulark 3 months, 3 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #14854

    regulark
    Participant

    Hello,

    I made a module for the object pool pattern to help with things like particles. It can be found on GitHub here: https://github.com/seankarol/lunchbox-pool
    Everyone is welcome to use it how they feel fit.

    In my little demo there I hover around 30 FPS with 300,000 particles in the pool while I’m about 22 FPS with the same amount in a regular list. I’m curious how it plays out in a more proper project.

    #15095

    Amon
    Participant

    Will test in a bit. Thank you anyway for this as it will be very handy on mobile devices.

    #15125

    nerobot
    Participant

    Some notes :

    • usually pool object provides constructor with capacity¬†parameter to be able to create needed size at startup
    • PurgeAvailable() – I never saw purge word in development, maybe classic Clear would be better
    • 2 linked lists under the hood (not good) – they will produce small allocations/deallocations for each add/remove operations that can be annoying for GC. I don’t know the best approach for optimizing that. For example, Pyro framework has ObjectPool class that uses 2 resizable arrays. They not so good when resizing occured but if you fill pool at startup it give better results – because there is no allocations/deallocations.
    #15133

    regulark
    Participant

    Cool, thanks for the feedback nerobot you make some good points!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.