Memory leak in the making?

I don’t know all that much about coding and programming, but this seems risky to me?

I know there’ll be a finish line eventually in the game, but just making more nebulae instead of reusing them (with code we’ve already learned), isn’t that better practice?

I don’t know if this is how memory leaks happen (putting in a million nebulae?), but I’m guessing it could be?

I’m asking to get to understand the pitfalls better. I realise this is a very resource-light game, but if I did this in a large game with large assets, would it be problematic, or wouldn’t it matter?

Memory leaks happen when data is created and then left all alone to tumble about in solitude in the wastelands that is the data stream. While that program or game is currently running.

In our case, we’re not creating pointers to objects in memory and we’re only creating them once before the game loop begins. When our game is closed, that memory will be released a be free for use by other applications.

If we were doing this while the game was running and during a reset of gameplay (such as a continue after game over), then it could become a problem mainly if we used pointers.

Which, you’ll learn more about with the next section!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms