Comments (3)
@Matt-Esch You couldn't close the transaction in the external string resource destructor because that would lead to unintuitive behaviour.
If you want to use strings (or buffers), either keep the transaction open for as long as you need to use them, or copy them. Take a look at this: #32
from node-lmdb.
That would lead to unintuitive behavior
Perhaps. I am using LMDB to index a large collection of translation strings from a read-only database. I was hoping to make use of the zero-copy property of LMDB to avoid string copies, but I don't know how long the string lives for other than it is a finite amount of time in the order of seconds (typical request cycle). A GC hooked transaction would be nice in this use case.
Buffers in node use the GC hooks to free memory, and I see a transaction as an external alloc.
from node-lmdb.
You know exactly how long the string lives: until you close the transaction with which you read it. (Meaning either commit or abort.) The memory in which they reside is owned by LMDB and is only guaranteed to be intact while you keep the transaction open.
If you need your strings for a longer time than that, you can copy them using one of the ways described above.
However since you are not the only one to ask about this, I might consider adding an API to node-lmdb that does the copying for you.
from node-lmdb.
Related Issues (20)
- {Question] Environment size and Delete HOT 2
- Modifying unsafe buffers in-place leads to segmentation fault HOT 3
- Build fails with Node 14.15.0, the new LTS release HOT 2
- Asynchronous batch write data types HOT 6
- Process memory balloons on create/close of multiple environments HOT 22
- Create github discussion board or slack for general questions
- Incremental backup and restore HOT 1
- Missing tags and releases on github?
- LMDB file gets created with maximum size when activating useWritemap option HOT 2
- Build errors under Node 16.1.0 HOT 9
- mdb_copy: copying failed, error -30784 (MDB_INCOMPATIBLE: Operation and DB incompatible, or DB flags HOT 2
- mkdirp throws error on running benchmark
- Use of deprecated Buffer in example code
- node-gyp rebuild error HOT 17
- property name readonly in `index.d.ts` should be readOnly HOT 1
- test: the worker thread in fact has no chance of receiving messages from the main thread
- In README.md you forgot to specify which kinds of "numbers" are supported HOT 1
- Append mode is not working correctly for string keys with character codes larger than 255 (MDB_KEYEXIST error) HOT 3
- Automatic map resizing HOT 3
- Program exit on Env.open HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-lmdb.