Size of a Vector of Pointers.

Posted on 2005-05-11
Last Modified: 2010-04-17

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.


Question by:hi_manas
    LVL 2

    Accepted Solution


    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.


    LVL 4

    Assisted Solution


    well the vectors are limited to size of your computers memory
    LVL 7

    Assisted Solution

    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.

    LVL 3

    Assisted Solution


    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.

    LVL 7

    Expert Comment

    How are you doing?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    A short article about a problem I had getting the GPS LocationListener working.
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now