You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note: You need to make sure that the compilation environment of the dynamic
library is the same as the installation and runtime environment of the memoryshare call.
darwin-x64
darwin-arm64
linux-x64-gnu
win32-x64-msvc
win32-ia32-msvc
linux-arm64-gnu
linux-arm64-musl
How to use
memoryshare support for data that can be serialized as string
Here is an example to guide how to share string data between different process
// main.jsimport{fork}from'child_process'import{init,setString,getString,clear,setBuffer,getBuffer}from'memoryshare'constmemId="string.link"constbufferMemId="buffer.link"clear(memId)clear(bufferMemId)init(memId,4096)// init share memory block with max size,each memId should be called only onceinit(bufferMemId,4096)functiongenerateBigString(){letbigStr='';for(leti=0;i<1;i++){bigStr+='Lorem ipsum dolor sit amet, consectetur adipiscing elit. ';}returnbigStr;}setString(memId,generateBigString())setBuffer(bufferMemId,Buffer.from(generateBigString()))fork('./child')// child.jsconstmemId="string.link"constdata=getString(memId)constbufferData=getBuffer(bufferMemId)