lundi 30 novembre 2015

Where is this function eat memory

When this function start and MAX_CHAIN_SIZE = 6 or 1 this function must work infinite time, but when it start, memory finished faster then time, for 1.5 second it s flow 64 - 67 mb. Where are I'm loose memory here? And HeshFunction have a distructor.

void FixedSet::Initialize(const vector<int>& numbers) {
    bool chainlong = true;
    int key;
    while (chainlong) {
        chainlong = false;
        srand(time(NULL));
        HeshFunction firstLayer(numbers.size());
        for (vector<int>::const_iterator currentNumber =    numbers.begin();
            currentNumber < numbers.end(); ++currentNumber)
        {
            firstLayer_ = firstLayer;
            heshtable_.resize(numbers.size());
            key = firstLayer_.heshing(*currentNumber);
            heshtable_[key].push_back(currentNumber[0]);
            if (heshtable_[key].size() > MAX_CHAIN_SIZE) {
                chainlong = true;
            }
        }
    }

class HeshFunction {
public:
int a_, b_, p_;
int tablesize_;
HeshFunction() {}
explicit HeshFunction(size_t tablesize);
int heshing(int key);
~HeshFunction(){}; };

Aucun commentaire:

Enregistrer un commentaire