PetteriAimonen / focus-stack

Fast and easy focus stacking
MIT License
294 stars 43 forks source link

Out Of Memory issue #4

Closed fraf0 closed 4 years ago

fraf0 commented 4 years ago

Hi,

Trying to work on 308 jpg files, I got an OOM. Do you think it's a normal behavior or it can be a memory leak somewhere? I tested with an 8go RAM computer (tested also in linux/recovery mode to maximize the free memory).

If you think there is a problem, I can provide you more information (logs, ...). If you think there is no problem, do you have tips to known which amount of memory I need regarding files I want to use?

Regards, fraf.

PetteriAimonen commented 4 years ago

You could try --threads=2 which will slow it down but reduce memory usage.

A log with --verbose could also be useful, though the issue is probably readily reproducible.

The main merging is done in batches of 8, but currently it keeps all source and grayscale images in memory for the final grayscale->color remapping step. An option could be added to reload them from disk at the end of merging.

fraf0 commented 4 years ago

Thank for your quick answer. Even with 2 threads (and the same with 1), I got an OOM.

Find here a log file generated with this command: $ focus-stack --no-whitebalance --no-contrast --threads=2 --verbose _MG_0*.jpg >focus.log 2>&1

focus.log

Ps.: I have another PC with 16Go (under windows) and I could generate the final image. I'm not in a hurry :) fraf.

PetteriAimonen commented 4 years ago

I have now added a commit that should keep memory usage to approximately 128 MBytes per each megapixel of resolution independent of the number of images, instead of the previous version that used more memory as the number of input images grew.

The new algorithm is active by default, as it has a quite small speed penalty of just a few percent and shouldn't increase memory usage even for small stacks. For large stacks the memory usage benefit is quite significant.

Here is memory log from a stack of 53 images of 0.8 megapixels each:

image