Skip to main content

2 posts tagged with "tutorial"

View All Tags

· 2 min read
Daniel Kalevski

Welcome to my blog post about improving game performance through the use of Object pools.

As a game developer, it's likely that you've had to deal with the problem of instantiating a large number of objects for a specific class, such as particles with a short lifetime that need to be destroyed. One of the challenges of this type of game logic is that JavaScript's model is based on the garbage collection pattern, which means that developers do not have direct control over allocated memory.


When memory locations (variables) are marked as null, they are collected by the garbage collector and removed from memory. However, when the garbage collector needs to dispose of a lot of objects, it takes a lot of processing time, which can negatively impact the performance of the game.

In that case, if you profile the memory, you will see something like what is shown in the picture below



But there's a solution to this problem, and it's called the Object pools pattern.

The Object pools pattern is an implementation that helps to reuse disposed objects instead of creating new ones. By reusing objects, we can reduce the number of objects that need to be created and collected by the garbage collector, which in turn improves the performance of the game.

After using Object pools, you will get results like this


Phaser Plus Object Pools

class CreateGameObjects extends Scene {

onCreate() {
this.pool.register('myObject', MyObject)

// create object using pool
let turtle = this.pool.obtain('myObject')

// remove object from scene and retreive back to the pool


· One min read
Daniel Kalevski


this is my first tutorial, so I hope it will be useful for all those who plan to start a new project using Phaser.

As part of a phaser-plus project I started recently, there is @phaser-plus/cli - a command line tool for creating and developing Phaser projects.

What is Phaser?

Phaser. is a free and open source software developed and owned by Richard Davey. You can visit their funding page and help them to make Phaser even better.

How do I make a project?

Before you start creating a project, you need to have NodeJS 16+ installed on your machine. If you already have NodeJS 16+ installed, you can create a project by executing:

npx @phaser-plus/cli init --template=phaser my-phaser-game

CLI Features

  • Simple setup
  • Hot module reload
  • Optimized production build
  • Support for Web workers