Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7681531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:21:46+00:00 2026-05-31T18:21:46+00:00

I am creating an Asteroids clone, but with a few more bells and whistles.

  • 0

I am creating an Asteroids clone, but with a few more bells and whistles.

As of right now I have an ArrayList<Asteroid> that holds all of the asteroids on screen. Each one has a Vector associated with it and extends my genereic GameObject class which handles the drawing and updating and other common things that each game object has in common.

That being said each time I destroy an asteroid I create a new Asteroid object and add it to the ArrayList<Asteroid>… There is a noticeable lag when this happens as I also create explosion particles and I assume this is the GC.

My idea was to instead of create new objects on the fly, that I can pre-create a pool of them and just re-use them.

Is this the right idea? Also what is the most organized and efficient way to go about that?

Any other ideas would be great as well. Just trying to reduce creating of all of these objects because it is definitely causing a noticeable lag. Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T18:21:47+00:00Added an answer on May 31, 2026 at 6:21 pm

    Creating a pool of objects and reusing them is a good idea. Also I think you could switch from ArrayList to Vector, because Vectors are optimized for random indexation, which you’ll do a lot when using a pool.

    Since you say that each time you destroy an asteroid, you add a new one, it seems that you work with a constant number of asteroids. So you could create pool with a constant number of members.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Creating liquid layouts is an immense pain. Now, I totally understand that tables should
Creating a Blackberry app. Just a beginner, I have searched but couldn't find a
Creating a Windows Forms Application in C#, I have a program that I am
Creating custom IHttpModules, I have realized that the requests for static files (e.g.: .css
Creating a JApplet I have 2 Text Fields, a button and a Text Area.
Creating shell output for a game, but don't want the window to scroll with
Creating an accordion - on the slide - the elements underneath the element that
Creating a patch is very easy in SubVersion, With Tortoise, you right-click and select
Creating a login page in xcode 4.2 I have the users fill out information
Creating an Iphone application, I used to perform INSERT QUERY on different databases. But

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.