Any simplified ManagedDB docs?


I’m still working on trying to implement Blevesearch to use BadgerDB; so far I’ve gotten all the tests passing by referring to Dgraph’s implementation of ManagedDB into a side library that bridges Blevesearch and BadgerDB.

The issue I’m having now is that I’m getting a memory leak somewhere and the application’s memory will grow exponentially leading to an out of memory panic eventually.

I’ve tried setting:

opt.TableLoadingMode = options.FileIO
opt.ValueLogLoadingMode = options.FileIO

Though doesn’t seem to fix anything; still grows pretty quickly. I have a feeling I might not be periodically calling something that’s doing garbage collection (or such)…

I already have goroutines handling the GC:

rv.vlogTicker = time.NewTicker(1 * time.Minute)
rv.mandatoryVlogTicker = time.NewTicker(5 * time.Minute)
go rv.runVlogGC()

runVlogGC() is pretty much the same as the Dgraph one:

func (s *Store) runVlogGC() {
	// Get initial size on start
	_, lastVlogSize := s.db.Size()

	runGC := func() {
		var err error
		for err == nil {
			// If a GC was successful, immediately run it again
			err = s.db.RunValueLogGC(0.7)
		_, lastVlogSize = s.db.Size()

	for {
		select {
		case <-s.vlogTicker.C:
			_, currentVlogSize := s.db.Size()
			if currentVlogSize < lastVlogSize+(100*MB) {
		case <-s.mandatoryVlogTicker.C: