-
Notifications
You must be signed in to change notification settings - Fork 7.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
memory allocated for default env is not deallocated #113
Comments
Comment #1 originally posted by sanjay@google.com on 2012-07-27T22:38:40.000Z: This is intentional so that leveldb can be used in programs that contain threads that are active while the process is exit-ing. If we attempted to clean up the default Env, we would end up causing problems for background threads. My recommendation is to use valgrind to report only non-reachable memory, and ignore or suppress any warnings related to reachable memory. Also, see the answers to: http://stackoverflow.com/questions/3840582/still-reachable-leak-detected-by-valgrind |
C++11 guarantees thread-safe initialization of static variables inside functions. This is a more restricted form of std::call_once or pthread_once_t (e.g., single call site), so the compiler might be able to generate better code [1]. Equally important, having less platform-dependent code in env_posix.cc makes it easier to port to other platforms. Due to the change above, this CL introduced a new approach for storing the singleton PosixEnv instance returned by Env::Default(). The new approach avoids a dynamic memory allocation, which eliminates the false positive from LeakSanitizer reported in #539 and #113 [1] https://stackoverflow.com/a/27206650/ ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=214293129
Libraries are treated as runtime objects on Windows
Original issue 107 created by gsai2007 on 2012-07-27T00:38:43.000Z:
What steps will reproduce the problem?
What is the expected output? What do you see instead?
Expected no memory leak.
==605== 512 bytes in 1 blocks are still reachable in loss record 11 of 13
==605== at 0x4C274B4: operator new(unsigned long) (vg_replace_malloc.c:287)
==605== by 0x79836C2: leveldb::InitDefaultEnv() (in /usr/local/maui/lib/libleveldb.so.1)
==605== by 0x8968B52: pthread_once (in /lib64/libpthread-2.11.1.so)
==605== by 0x7982A26: leveldb::Env::Default() (in /usr/local/maui/lib/libleveldb.so.1)
==605== by 0x7985FFC: leveldb::Options::Options() (in /usr/local/maui/lib/libleveldb.so.1)
==605== by 0x4EAFBB1: KVStoreStage::KVStoreStage(char const_) (kvstorestage.cxx:44)
==605== by 0x4EAFCFF: KVStoreStage::makeStage(std::string const&, Properties_) (kvstorestage.cxx:252)
==605== by 0x5658525: ClassFactory<Stage>::makeInstance(std::string const&, Properties*) (classfactory.hxx:150)
==605== by 0x5656945: SedaConfig::instantiate() (sedaconfig.cxx:334)
==605== by 0x5658388: SedaConfig::init() (sedaconfig.cxx:215)
==605== by 0x464259: main (kvs.cxx:120)
env.h
class Env {
public:
Env() { }
virtual ~Env();
// Return a default environment suitable for the current operating
// system. Sophisticated users may wish to provide their own Env
// implementation instead of relying on this default environment.
//
// The result of Default() belongs to leveldb and must never be deleted.
static Env* Default();
What version of the product are you using? On what operating system?
1.5.0, OS Suse Linux 11
Please provide any additional information below.
The text was updated successfully, but these errors were encountered: