Open xty1992a opened 2 years ago
Hi @xty1992a,
It looks like you may be using Node.js. Have you tried increasing the max memory usage of your node process with --max-old-space-size=<memory in MB>
?
Hi @xty1992a, It looks like you may be using Node.js. Have you tried increasing the max memory usage of your node process with
--max-old-space-size=<memory in MB>
?
Yes but still.
I google this that say this flag is useless now
Versions of Node that are >= 12 should not need to use the --optimize_for_size and --max_old_space_size flags because JavaScript heap limit will be based on available memory.
And I had print the process. memoryUsage()
before toPng and after.
when I export some image that smaller then the collapse one, It use about 100-200MB memory.
I`ll post the detail later : )
Ahh interesting, in that case the process should use as much available memory as possible. Could either be that there's a leak somewhere in the code or that the file is just that dang large. Either way unfortunately don't have an easy solution to this. I'll take a look at the details if you post them.
sorry for waiting...
test code below
PSD.open(root("data/psd/1/地产20.psd"))
.then(async (psd) => {
const tree = psd.tree();
const children = tree.children();
const big = children.find((it) => it.name === "131369335"); // some image 3543 * 2657
// const big = children.find((it) => it.name === "313682976"); // some image 5406 * 6235
console.log(big.layer.image);
console.log("before", process.memoryUsage());
const png = big.layer.image.toPng();
console.log("after", process.memoryUsage());
return png;
})
.then(() => {
console.log("Finished!");
})
.catch((e) => {
console.log("error", e.message);
});
the print
before {
rss: 121024512,
heapTotal: 26951680,
heapUsed: 11277496,
external: 74811088,
arrayBuffers: 73624113
}
after {
rss: 1889210368,
heapTotal: 1790042112,
heapUsed: 1754777680,
external: 112403396,
arrayBuffers: 111216381
}
You can download this psd for test also
Interesting! Thanks for posting more information. I'm a bit locked up this week but I'll try and take a look at this case over the weekend.
Hello
I have some psd file, and I need export some image from it. my code like this
and the
layder.image
be like thisLayder.image
``` LazyExecute { obj: ChannelImage { layer: Layer { file: [File], header: [Header], mask: [Mask], blendingRanges: [Object], adjustments: [Object], channelsInfo: [Array], blendMode: [BlendMode], groupLayer: null, infoKeys: [Array], top: -637, left: -1046, bottom: 5598, right: 4360, channels: 4, height: 6235, rows: 6235, width: 5406, cols: 5406, opacity: 255, visible: true, clipped: false, layerEnd: 36230, legacyName: '313682976', objectEffects: [Function], layerNameSource: [Function], layerId: [Function], blendClippingElements: [Function], blendInteriorElements: [Function], locked: [Function], metadata: [Function], image: [Circular], node: [Layer] }, _width: 5406, _height: 6235, file: File { data:then I got message like this
collapse message
``` <--- Last few GCs ---> [13840:000001FD3F55A360] 6818 ms: Scavenge 1040.1 (1058.2) -> 1031.7 (1061.9) MB, 3.9 / 0.0 ms (average mu = 0.848, current mu = 0.942) allocation failure [13840:000001FD3F55A360] 6826 ms: Scavenge 1043.6 (1061.9) -> 1035.3 (1065.2) MB, 3.8 / 0.0 ms (average mu = 0.848, current mu = 0.942) allocation failure [13840:000001FD3F55A360] 6835 ms: Scavenge 1047.1 (1065.2) -> 1038.9 (1068.7) MB, 4.0 / 0.0 ms (average mu = 0.848, current mu = 0.942) allocation failure <--- JS stacktrace ---> ==== JS stack trace ========================================= 0: ExitFrame [pc: 00007FF71FBDABBD] Security context: 0x0105560c08d1my device is windows10, 16G ram. and node version is 12.20.0 psd version is 3.2.0
Good day.