[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 298
  • Last Modified:

Size of a Vector of Pointers.

Hi,

Is there a limitation to the size of a vector of pointers? Earlier we were storing the objects in a vector. Due to memory problems (core dump), we changed the vector definition to store pointers to the objects instead of the objects themselves. However, the problem still reappears with very large population. The population is in the range of millions.

Thanks.

-Manas
0
hi_manas
Asked:
hi_manas
4 Solutions
 
Beer7ChildCommented:
Hi,

Assuming the vector's implementation uses a contigous memory block to store all the pointers
sequentiually, then if memory is highly fragmented, the vector may fail to reallocate a larger
memory block as the vector grows. However, that  problem should be quite appearent from the crash
dump - you should  see that the allocation routine failed.

Besides (un)availability of memory, there should be no problem having a vector holding
at least 100 millions pointers (assuming you work on a 32-bit platform).

Perhaps the crash is due to some other memory corruption in the software.

It will help if you can provide more details :
Which OS are you working on.
What langugae you use.
How is the vector implemented
The nature of teh crash - Null pointer access, or corrupted memory.

Thanks,
beer7Child

0
 
furqanchandioCommented:
hi

well the vectors are limited to size of your computers memory
0
 
SoyYopCommented:
It's a good idea to use a pointer to an array. If your requirements are dynamic, think on an array of lists, or a binary tree... requires a bit more memory, BUT, works with smaller chunks of data that are asy to realloc.

On Windows, virtual memory can allocate around 2GB for data. I've worked with that.

On Unix, I think must be near that... sometimes, you can have 4GB implementations on 32 bits processors.

0
 
mathbiolCommented:
Manas,

You could probe your system to see how large the population has to be to get a core dump.

Maybe two vectors would work better than one vector.  Store the first half of the pointers in one vector, and the other half in the second vector.  As you're populating your objects, you could see if you've gotten to the "full" state, and if so, store the new object in the "overflow" vector.  I hope this doesn't cause you too many headaches for retrieving objects.

mathbiol
0
 
SoyYopCommented:
How are you doing?
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now