Git Product home page Git Product logo

Comments (4)

Dmarcoux111 avatar Dmarcoux111 commented on May 29, 2024

@ozra

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.

Dmarcoux111 avatar Dmarcoux111 commented on May 29, 2024

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.

Dmarcoux111 avatar Dmarcoux111 commented on May 29, 2024

@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.

UmanShahzad avatar UmanShahzad commented on May 29, 2024

We made https://github.com/ipinfo/mmap-utils with a fix for this.

from mmap-io.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.