Closed ghost closed 8 years ago
Setting a finalizer is not necessary. The NewEnv function sets a finalizer for every Env.
https://github.com/bmatsuo/lmdb-go/blob/master/lmdb/env.go#L76
However, you should attempt to make your calls to Env.Close explicit. The finalizers on types in the LMDB package are provided as a safety net to avoid leaking memory allocated in C. But, finalizers are not dependable for cleaning up resources quickly, and they are not guaranteed to always run before termination.
I would suggest you write a Close method for your QEnv type and call it when the QEnv is no longer in use.
@bmatsuo Get it! Thank you
Execute me, @bmatsuo Below is my code:
I'm not sure if I need call
and when golang gc, will golang collect the pointers in a struct object?