|
-
Mar 31st, 2003, 07:40 PM
#1
Thread Starter
Frenzied Member
Vector and memory
I have a struct:
struct UT210
{
string sLID;
string sCID;
};
And a vector that uses the struct:
vector<UT210> vecUT210AP;
And a temp var in my function:
UT210 stUT210;
That takes in results from an sql fetch, which does a select * from the table:
Code:
while ( !g_bBottomRecord)
{
i++;
stUT210.sLID = (char*)m_Data[1];
stUT210.sCID = (char*)m_Data[0];
vecUT210AP.push_back(stUT210);
Fetch();
}
In total there are around 34,000 records to be taken in.
The problem I have is that I get an out of memory error, which I am going to guess is caused by the increasing of the vector. So am I doing something wrong here? Is there a better way to do this? Am I just putting to much data into this vector.
Oh my machine is a 3GHz HT w/ 4GB of RAM so I doubt that its my machine.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

-
Apr 1st, 2003, 05:17 AM
#2
Member
Hi!!
If m_Data array already has data stored in it and m_Data is not being deleted after copying the data in the vector then it is better to store the address(pointer) to respective data than to store the whole data. That may solve the memory problem
Regards
Shaunak
-
Apr 15th, 2003, 01:46 AM
#3
Also you should try to find out the number of rows and use vector::reserve to allocate memory in advance to speed things up.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Apr 15th, 2003, 10:07 AM
#4
Thread Starter
Frenzied Member
Did that already and it helped alot. I was also leaking a little on the fetch which wasn't helping.
MSVS 6, .NET & .NET 2003 Pro
I HATE MSDN with .NET & .NET 2003!!!
Check out my sites:
http://www.filthyhands.com
http://www.techno-coding.com

Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|