code: func (db *DB) newMem(n int) (mem *memDB, err error) {
  	fd := storage.FileDesc{Type: storage.TypeJournal, Num: db.s.allocFileNum()}
  	w, err := db.s.stor.Create(fd)
  	if err != nil {
  		db.s.reuseFileNum(fd.Num)
  		return
  	}
  
  	db.memMu.Lock()
  	defer db.memMu.Unlock()
  
  	if db.frozenMem != nil {
  		return nil, errHasFrozenMem
  	}
  
  	if db.journal == nil {
  		db.journal = journal.NewWriter(w)
  	} else {
  		db.journal.Reset(w)
  		db.journalWriter.Close()
  		db.frozenJournalFd = db.journalFd
  	}
  	db.journalWriter = w
  	db.journalFd = fd
  	db.frozenMem = db.mem
  	mem = db.mpoolGet(n)
  	mem.incref() // for self
  	mem.incref() // for caller
  	db.mem = mem
  	// The seq only incremented by the writer. And whoever called newMem
  	// should hold write lock, so no need additional synchronization here.
  	db.frozenSeq = db.seq
  	return
  }
docs: // Create new memdb and froze the old one; need external synchronization.
  // newMem only called synchronously by the writer.