ostafen / clover

A lightweight document-oriented NoSQL database written in pure Golang.
MIT License
633 stars 54 forks source link

Cannot allocate initial memory #105

Open cmbbr opened 1 year ago

cmbbr commented 1 year ago

Hello,

I'm starting a project where, after some research, I would like to embed clover db. I've started to tried it but I'm getting kernel panic due to memory allocation.

I was going through past issues and I read issue https://github.com/ostafen/clover/issues/35 , so I made sure I'm using db.Close(), actually my code is just your repply to that issue:

db, err := c.Open("./db")
defer db.Close()
if err != nil {
    panic(err)
}

After which I get a kernel panic saying:

cannot allocate memory while mmapping ./db2/000001.vlog with size: 2147483646

My question is: is there a way to configure the db so it doesn't reserve so much memory from the start?

Thank you for your work.

ostafen commented 1 year ago

Hi, @cmbbr, there problem here is that badgerDB is very memory demanding.

Give a look at this PR: https://github.com/ostafen/clover/pull/99 In that branch, I'm integrating support for supporting both boltDB and badgerDB. Maybe using boltDB for you could be better, since it's really less memory demanding.

Let me know if you are able to use that branch and if it works for you. I'll have it merged soon