Click here to Skip to main content
15,867,964 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
See more:
What's the problem? Is it a memory leak? I don't quite understand how that is possible because I run a 64 bit machine and got like 12 GB of RAM. What can cause it? I've been thinking it's due because I use a string vector and the string vector in the stack disappears at some point. How do I debug this and what can I do, I am inexperienced in memory management.

XML
vector<Info> final;

vector<Info>::iterator col;
vector<string>::iterator coll;

coll = nameVector.begin();

for (col = vec.begin(); col != vec.end(); col++)
{

    (*col).setName(*coll); //this line

    coll++; 



    final.push_back(*col);



}
Posted
Updated 22-Feb-14 9:54am
v3
Comments
Maarten Kools 22-Feb-14 15:37pm    
Segmentation faults[^] indicate corrupt memory. For example dereferencing a pointer that is already freed, or having a buffer overflow would do the trick as well. Is it possible for you to post your code? If it's not a huge amount, we might be able to help you spot the error.
Member 10338805 22-Feb-14 16:08pm    
the weird thing is tht it works fine with smaller data sets
Maarten Kools 22-Feb-14 16:12pm    
What does the Info class look like, and what is the implementation of the setName function look like?
Maarten Kools 22-Feb-14 16:24pm    
One thing that does stand out for me on this code is that there's no check on whether coll is valid in the loop. The code assumes that both vec and nameVector are equal in length. However, if nameVector has less elements than vec you have a problem (and potential segfault).
CPallini 22-Feb-14 16:39pm    
Yes, that is, in my opinon.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900