Re: How to create a 10000000000 size array ?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: josh (smileyfaceswillruletheworld_at_yahoo.com.NOSPAM)
Date: 09/24/04


Date: Thu, 23 Sep 2004 17:24:23 -0700

I hate VC very much wrote:
> um.....maybe I should not write 100000000000000....
> actually, what I want it to create is a pointer(LPVOID) array which can store
> 4294967296 elements, ie. it can store totally 32bits elements
>
> I just want a class of array which does not use MFC.
> If anyone knows it, please answer me. Thanks..

If your pointers are the same size as the minimum addressable unit, you
can cover the entire address space, but you won't have room for anything
else. eg, if your pointers are 8-bits wide and your memory is divided
into octets, you have 256 memory locations and room for exactly 256
pointers.

In Win32, pointers are 4 times the size of the minimum addressable unit.
  You have 4 billion memory locations, but only room for 1 billion
pointers in your address space. Actually you have a lot less than this,
since the OS and your code take up a lot of space, and presumably you're
not just pointing to other places in your array, so you need room for
those other objects.

You probably want to look at some sort of "sparse" array structure, or
rethink the whole thing from the beginning. Do you really need to cover
the entire addressable space? Do you really need to cover it at a
1-byte resolution? Do you really need to store these pointers at all,
or are they constants that you can think away into conceptual oblivion?

-josh



Relevant Pages

  • Re: Differance between Array and Pointers
    ... Well, except that arrays tend to be much larger than pointers, and the ... An array is a contiguous region of memory containing N elements of M ... indexing vs. a loop). ...
    (comp.arch.embedded)
  • [RFCv2][PATCH] flexible array implementation
    ... I call it a flexible array. ... storage for pointers to the second level. ... all locking must be provided by the caller. ... make sure to pass in &ptr instead of ptr. ...
    (Linux-Kernel)
  • [RFC][PATCH] flexible array implementation v4
    ... I call it a flexible array. ... so never does an order>0 allocation. ... storage for pointers to the second level. ... all locking must be provided by the caller. ...
    (Linux-Kernel)
  • Re: [RFC][PATCH] flexible array implementation v4
    ... I call it a flexible array. ... so never does an order>0 allocation. ... storage for pointers to the second level. ... all locking must be provided by the caller. ...
    (Linux-Kernel)
  • Re: Garbage produced
    ... section on pointers and arrays is very hard to understand... ... much better to have two kinds of pointers: Array Pointers (these would be ... It's unnecessary - scanf() protects against invalid input. ... You need an extra buffer. ...
    (comp.lang.c)