c++ - std::queue memory deallocation does not work -
i have basic class push member 1 thread , pop another.but debugged memory leak validator see memory not freed , validator show leak issue @ pushing stage.in class have array not dynamic.
my_class{ int my_var1; int my_var22; int my_array[100000]; my_class& operator=(const my_class& old){ if(this!=&old){ var1=old.var1; var2=old.var2; memcpy(my_array,old.my_array,size) //size fixed same 100000 } my_class(const my_class ©){ *this=copy; } }; //here reading data udp , copy array var1; my_class var1; my_class var2; int udp_array[]; //thread 1 while(haspendingdata()){ udp_array.fill(); //my_array filled after loop } //than mem_cpy(var1.my_array,udp_array,size); my_mutex.lock(); std::my_queue.push(var1); my_mutex.unlock(); //thread 2 my_mutex.lock(); var2=my_queue.front(); my_queue.pop(); my_mutex.unlock();
Comments
Post a Comment