B
brey_maastricht
Hello guys,
I really need your help. I'm a Java programmer and right now I'm
experiencing a huge problem with C++.
In a scientific computation I need to store a lot of Point objects
(which have an array of doubles and 2 ints as fields).
To quickly search among all these points I have designed a Hashtable
to store them; a bucket/vector of buckets/vectors.
The hashtable is filled with Points objects in a while loop.
This whole procedure again is repeated a lot of times in a for loop.
At the end of every run of this for loop the Hashtable has to be
emptied in order to prevent for memroy leaks: this means looping
through every vector in the main vector of the hashtable and delete
every Point object manually.
Later on, this C++ computation will be compiled under Matlab to use it
over there.
But now the problem is:
My C++ programm is very fast without emptying the hashtable. But then
I have a huge memory leak; and my swapfile grows enormouly.
With emptying the hashtable my C++ programm becomes dramatically
slow.....even slower than my Java programm.
So the question is: What to do now ?? It cannot be the case that
preventing a memory leak, slows down the computations ??
Kind regards,
Brey
I really need your help. I'm a Java programmer and right now I'm
experiencing a huge problem with C++.
In a scientific computation I need to store a lot of Point objects
(which have an array of doubles and 2 ints as fields).
To quickly search among all these points I have designed a Hashtable
to store them; a bucket/vector of buckets/vectors.
The hashtable is filled with Points objects in a while loop.
This whole procedure again is repeated a lot of times in a for loop.
At the end of every run of this for loop the Hashtable has to be
emptied in order to prevent for memroy leaks: this means looping
through every vector in the main vector of the hashtable and delete
every Point object manually.
Later on, this C++ computation will be compiled under Matlab to use it
over there.
But now the problem is:
My C++ programm is very fast without emptying the hashtable. But then
I have a huge memory leak; and my swapfile grows enormouly.
With emptying the hashtable my C++ programm becomes dramatically
slow.....even slower than my Java programm.
So the question is: What to do now ?? It cannot be the case that
preventing a memory leak, slows down the computations ??
Kind regards,
Brey