Struct json_struct
{
String tableName;
Map
Vector
};
Int delete_jsonvector (vector
If (NULL!=vc_json)
{
Cstrings ToLog;
Size_t SIZE=0;
Vector
{
For (vector
{
Vector
If (temp!=NULL)
{
SIZE=SIZE + _msize (temp);
Temp - & gt; clear();
The delete temp.
Temp=NULL;
}
Iter iter2=(*) - & gt; The value - & gt; Erase (iter2);
}
If ((* iter) - & gt; The value!=NULL)
{;
SIZE=SIZE + _msize (iter (*) - & gt; Value);
(* iter) - & gt; The value - & gt; clear();
Delete (* iter) - & gt; value;
(* iter) - & gt; Value=https://bbs.csdn.net/topics/NULL;
}
If ((* iter) - & gt; The name!=NULL)
{
SIZE=SIZE + _msize (iter (*) - & gt; Name);
(* iter) - & gt; The name - & gt; clear();
Delete (* iter) - & gt; name;
(* iter) - & gt; Name=NULL;
}
Iter json_struct * temp=(*);
Iter=vc_json - & gt; Erase (iter);
If (temp!=NULL)
{
SIZE=SIZE + _msize (temp);
The delete temp.
Temp=NULL;
}
}
If (vc_json!=NULL)
{
SIZE=SIZE + _msize (vc_json);
The delete vc_json;
Vc_json=NULL;
}
ToLog. The Format (" delete % d size, size); WriteLogInfo (ToLog);
}
return 1;
}
CodePudding user response:
Can see out the specific information?Personal advice,
1 write a test program, this part separately, insert some data clean up again, to see whether there is leakage
Insert this part 2 and clean up the blocked test again to see whether there is a leak?
3 single step debugging or insert log, see run the process and the data is correct
4 to consider whether there is a cross-border or pointer modified
CodePudding user response:
There are many memory leaks is false, connect the compiled code using static library to see if will leak?Or will use additional DLLS in the connector Settings, try to use lazy loading,
CodePudding user response:
Now is really a headache, memory to see rose up slowly, the project is large, how to position is good?CodePudding user response:
If it is to write their own code, online have a memory leak detection, the method of using the macro definition malloc and free memory allocation function, such as rewriting new delete method, the goal is to make code where the memory allocation and release is done by you to define the function of rewriting, so I can record when calls to allocate memory memory allocation code location, size of memory allocation, and maintain the information, when the free memory, delete the information, at the end of the program, look at what information has not been deleted, that is how many memory leaks, because the memory allocation is recorded the information, so I can see where is assigned the no release,CodePudding user response:
You can see this really release vc_json space?Int delete_jsonvector (vector
If (NULL!=vc_json)
{
//cstrings ToLog;
//size_t SIZE=0;
Vector
{
For (vector
{
If (* iter2!=NULL)
{
The delete * iter2;
* iter2=NULL;
}
}
(* iter) - & gt; The value - & gt; clear();
If ((* iter) - & gt; The value!=NULL)
{
Delete (* iter) - & gt; value;
(* iter) - & gt; Value=https://bbs.csdn.net/topics/NULL;
}
If (* iter!=NULL)
{
The delete * iter.
* iter=NULL;
}
}
Vc_json - & gt; clear();
If (vc_json!=NULL)
{
The delete vc_json;
Vc_json=NULL;
}
}
return 1;
}