kidok / protobuf

Automatically exported from code.google.com/p/protobuf
0 stars 0 forks source link

memory leak #675

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
A memory leak is detected by vld(visual leak detector).
I think the problem is caused by this function:
void InitEmptyString() {
  empty_string_ = new string;
}
empty_string_ will not be deleted later.

In previous version protobuf-2.5.0, empty string is a global std::string
const ::std::string kEmptyString;

protobuf version: protobuf-2.6.0
OS: windows 8.1
build env: visual studio 2013

Some output generated by vld:
d:\sdk\protobuf\protobuf-2.6.0\src\google\protobuf\generated_message_util.cc 
(55): ChatServerd.exe!google::protobuf::internal::InitEmptyString + 0x7 bytes
d:\sdk\protobuf\protobuf-2.6.0\src\google\protobuf\stubs\common.h (876): 
ChatServerd.exe!google::protobuf::internal::FunctionClosure0::Run + 0xA bytes
d:\sdk\protobuf\protobuf-2.6.0\src\google\protobuf\stubs\once.cc (83): 
ChatServerd.exe!google::protobuf::GoogleOnceInitImpl + 0xF bytes
d:\sdk\protobuf\protobuf-2.6.0\src\google\protobuf\stubs\once.h (127): 
ChatServerd.exe!google::protobuf::GoogleOnceInit + 0xD bytes
d:\sdk\protobuf\protobuf-2.6.0\src\google\protobuf\generated_message_util.h 
(84): ChatServerd.exe!google::protobuf::internal::GetEmptyString + 0xF bytes

Original issue reported on code.google.com by vxm...@gmail.com on 20 Oct 2014 at 1:54

GoogleCodeExporter commented 9 years ago
Fixed in:
https://github.com/google/protobuf/commit/06e6690bf2055b4361db2a6bdd21facf3f2d86
d6

Original comment by xiaof...@google.com on 20 Oct 2014 at 5:46