Skip to content

Commit

Permalink
Apply memory limits per ncruces suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
mtlynch committed Sep 12, 2024
1 parent 4c6a0bf commit 632e08a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions store/sqlite/sqlite.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@ import (
"log"
"time"

"github.com/ncruces/go-sqlite3"
"github.com/ncruces/go-sqlite3/driver"
_ "github.com/ncruces/go-sqlite3/embed"
"github.com/ncruces/go-sqlite3/ext/blobio"
"github.com/tetratelabs/wazero"

"github.com/mtlynch/picoshare/v2/picoshare"
)
Expand Down Expand Up @@ -51,6 +53,10 @@ func New(path string, optimizeForLitestream bool) Store {
}
}

// Try to prevent memory exhaustion.
// https://github.com/ncruces/go-sqlite3/issues/148#issuecomment-2344857749
sqlite3.RuntimeConfig = wazero.NewRuntimeConfig().WithMemoryLimitPages(512)

applyMigrations(ctx)

return Store{
Expand Down

0 comments on commit 632e08a

Please sign in to comment.