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

  • SEARCH
  • Home
  • 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 7584171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:51:22+00:00 2026-05-30T18:51:22+00:00

I have a 3D game where objects are stored in a 3D array. Every

  • 0

I have a 3D game where objects are stored in a 3D array. Every object is a struct of a relatively large size (a few megabytes, 4,194,304 bytes to be precise).

If I store them as an array of raw values: gameObject objects[64][64][8], they are all stored in one place, but every object is allocated, regardless of whether or not it is used.
However, if I allocate the array as an array of pointers: gameObject *objects[64][64][8], unused objects (which may be over half of the entire array) will not be allocated until they are needed, reducing the memory impact, but might be slower because the objects are all over the memory

Considering the tradeoffs between performance and memory usage, which is the best approach? Are my concerns valid?

  • 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-30T18:51:23+00:00Added an answer on May 30, 2026 at 6:51 pm

    [the second approach] might be slower because the objects are all over the memory

    Since every object is 4MB in size, locality of reference across different objects is almost certainly not an issue. Go with the second approach.

    If the numbers you’re giving us are correct, a fully populated array of 128x128x128 4MB objects would require about 8TB of RAM, which makes the first approach somewhat infeasible on typical hardware. 😉

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

Sidebar

Related Questions

I have an object: POP_CULTURE_TYPES = ( ('SG','Song'), ('MV', 'Movie'), ('GM', 'Game'), ('TV', 'TV'),
I'm building a game in XNA 3 and I have the levels stored in
I am making a 2d space game with many moving objects. I have already
Dear all, this is going to be tough: I have created a game object
Let's say I'm creating an OpenGL game in C++ that will have many objects
I have a C++ std::vector denoted as: std::vector<GameObject*> vectorToSort; Each object in vectorToSort contains
I'm developing a game. I want to have game entities each have their own
I am trying to code a global lookup table of sorts. I have game
I have an game application I have written for Windows Mobile and I want
I have a game in which you can score from -40 to +40 on

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.