Code gets really slow when Class Has Vector

Discussion in 'General Computer Support' started by eklein, Jun 26, 2007.

  1. eklein

    eklein

    Joined:
    Jun 25, 2007
    Messages:
    1
    Likes Received:
    0
    So the question I have is when I have a vector of a class with a vector of another class inside it (or even a large array), when the number items in my first vector gets large, execution slows to a crawl. Does anybody know why this would be? It actually only happens in Windows (using cygwin compiler). On a Linux machine it works fine. Does anyone know why this would be? (And please don't tell me I shouldn't be using windows, the application is supposed to be able to be used cross-platform).

    class m {
    public:
    m(); // constructor
    ~m(); // destructor

    m(const m& m2); //copy constructor

    // some calls here

    private:
    vector<anotherclass> p;

    };

    vector<m> vect_m;

    for(int i=0;i<3000;i++) {
    m mi;
    vect_m.push_back(mi);
    }
     
    Last edited: Jun 26, 2007
    eklein, Jun 26, 2007
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.