Dynamic Memory Efficiency

This is a discussion on Dynamic Memory Efficiency within the C Programming forums, part of the General Programming Boards category; I need a large 3D array (typical size 4000x400x3) in my program. Which is more efficient of - (1) dynamically ...

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    6

    Dynamic Memory Efficiency

    I need a large 3D array (typical size 4000x400x3) in my program. Which is more efficient of -
    (1) dynamically allocate a 1D array, then use index calculation (I am thinking of a macro) to simulate 3D array
    (2) dynamically allocate 3D array and use it directly.

    Will things change for a 2D array?

    In my program, the array elements will be referenced like 2-4 million times in a typical execution.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,175
    If you're looking for raw speed, I'd lean toward the 1D array using index calculation, but the only way you'll really find out for sure is to try it both ways and see which one works best for you.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Copy .dat file to dynamic memory...
    By IndioDoido in forum C Programming
    Replies: 5
    Last Post: 05-28-2007, 05:36 PM
  2. Inheritance and Dynamic Memory Program Problem
    By goron350 in forum C++ Programming
    Replies: 1
    Last Post: 07-02-2005, 03:38 PM
  3. Is it necessary to write a specific memory manager ?
    By Morglum in forum Game Programming
    Replies: 18
    Last Post: 07-01-2002, 02:41 PM
  4. dynamic memory + linked lists
    By Unregistered in forum C Programming
    Replies: 1
    Last Post: 02-10-2002, 04:50 PM
  5. Dynamic Memory Allocation for fstream (binary)
    By kuphryn in forum C++ Programming
    Replies: 2
    Last Post: 12-12-2001, 10:52 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21