Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows CreateFileMapping: Not enough memory resources #252

Closed
lunemec opened this issue Nov 10, 2020 · 2 comments
Closed

Windows CreateFileMapping: Not enough memory resources #252

lunemec opened this issue Nov 10, 2020 · 2 comments

Comments

@lunemec
Copy link

lunemec commented Nov 10, 2020

I have a issue opening large DB files on Windows.

The code does not do much here: https://github.com/lunemec/ed-router/blob/96c8fa872b48b5eb83c6afb2b31b24d8106ddbc5/pkg/db/boltdb/boltdb.go#L46

The error I get:

Error: unable to open database: unable to open index DB: index_xyz.db: CreateFileMapping: Not enough memory resources are available to process this command.

The DB files I have are pretty big:

10/11/2020  17:05    35,615,076,352 galaxy.db
10/11/2020  17:10    16,660,320,256 index_xyz.db

The strange thing is, this code works just fine on my MacOS MBP with only 4GB Ram, but not on my Windows machine with 32GB ram, even with swap file enabled to up to 32GB.

How do I open these large databases on windows?

I run Windows 10 Home, version 1083, build 17134.1069 64bit.

@jonstelly
Copy link

jonstelly commented Jun 24, 2022

I'm working on a PR for an etcd snapshot feature, I fixed an issue in that PR but then I'm running into this issue. I notice the CreateFileMapping call from the Windows API has the parameters as sizeHigh then sizeLow but in bbolt, the parameters look reversed.

Does this fix look right? I'm not really a go developer so I don't know how I'd go about testing this but I can submit a PR blind if this is a straightforward.

bolt_windows.go:72

index 09e00b6..a5a08e9 100644
--- a/bolt_windows.go
+++ b/bolt_windows.go
@@ -72,7 +72,7 @@ func mmap(db *DB, sz int) error {
        // Open a file mapping handle.
        sizelo := uint32(sz >> 32)
        sizehi := uint32(sz) & 0xffffffff
-       h, errno := syscall.CreateFileMapping(syscall.Handle(db.file.Fd()), nil, syscall.PAGE_READONLY, sizelo, sizehi, nil)
+       h, errno := syscall.CreateFileMapping(syscall.Handle(db.file.Fd()), nil, syscall.PAGE_READONLY, sizehi, sizelo, nil)
        if h == 0 {
                return os.NewSyscallError("CreateFileMapping", errno)
        }

@ahrtr
Copy link
Member

ahrtr commented Sep 4, 2024

This issue should have already been fixed,

h, errno := syscall.CreateFileMapping(syscall.Handle(db.file.Fd()), nil, syscall.PAGE_READONLY, sizehi, sizelo, nil)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants