Comments (4)
Update... I tried just mapping the file as 1gb chunks and I run into the same error after gig number 2...
*note, mapping the file works fine with python's numpy.memmap
Codez:
`// const file = path.join( remote.app.getAppPath(), 'pointclouds', 'las', 'test.las' )
const file = path.join( remote.app.getAppPath(), 'test.tif' )
const size = fs.statSync( file ).size
const fd = fs.openSync( file, 'r' )
const pages = []
const bufferSize = 2**30
console.time('test')
for ( let offset = 0; offset < size; offset+=bufferSize ) {
console.log( 'start:', offset )
let pageSize = bufferSize;
if ( pageSize > size ) {
pageSize = size % bufferSize
}
console.log( pageSize )
const protection = window.MMAP.PROT_READ
const privacy = window.MMAP.MAP_PRIVATE
const advise = window.MMAP.MADV_RANDOM
const buffer = window.MMAP.map( pageSize, protection, privacy, fd, offset, advise )
pages.push( buffer )
console.log( 'end:', offset + pageSize )
console.log( '\n\n' )
}
console.timeEnd('test')`
results in:
Uncaught Error: mmap failed, 0
from mmap-io.
Another update... If I allocate 4 1gb buffers on the same file starting at offset 0, there is also no issue. It seems like maybe the issue is the number being passed into either offset or size?
from mmap-io.
@ozra So I actually fixed this by changing the type of the input arguments for size and offset to long longs.... idk if this breaks things on other architectures, but posting my answer here for anyone that runs into a similar problem.
`
constexpr void* hinted_address = nullptr; // Just making things uber-clear...
const size_t size = static_cast<size_t>(get_v<long long>(info[0]));
const int protection = get_v<int>(info[1]);
const int flags = get_v<int>(info[2]);
const int fd = get_v<int>(info[3]);
const size_t offset = static_cast<size_t>(get_v<long long>(info[4], 0));
const int advise = get_v<int>(info[5], 0);
`
*disclaimer, I haven't written C plus plus in like 5 years so be cautious
from mmap-io.
We made https://github.com/ipinfo/mmap-utils with a fix for this.
from mmap-io.
Related Issues (20)
- nan dependency version HOT 7
- npm install fails on Windows HOT 14
- Module is not Context-Aware. Creates module registration error with node js worker threads HOT 5
- Compiler warnings b/c V8 changes. Consider "node_addon_api" over "NAN"
- After upgrade to 1.1.0, the module cannot be imported HOT 7
- Readme reference Make HOT 1
- Invalid arg type The "path" argument must be one of type string, Buffer or URL. Received type number. HOT 1
- Can this do memory mapped not to file (e.g. not persisted/stored to/from disk)? HOT 2
- Current NAN fails for node 12.6.0, time for beast coding
- Ability to get SharedArrayBuffer instead of ArrayBuffer
- Ability to explicitly unmap
- Release new version from latest master HOT 2
- TypeScript api sample?
- Bus error if 'offset' of mmap is greater than 2gb. HOT 1
- Build folder is empty and compatibility with phone apps
- Add minimal node example to Readme
- Does not build for node 22 HOT 1
- windows: incorrect split between high and low for position and offset HOT 3
- windows: always creating paging mapping, not file mapping HOT 2
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 mmap-io.