library icon indicating copy to clipboard operation
library copied to clipboard

Memory leak when continuously decoding for long time

Open urkku opened this issue 4 years ago • 4 comments

Describe the bug It seems like there is a memory leak when decoding QR code continuously. Memory footprint seems to be increasing around 30mb/15min and in 1 hour memory footprint has increased by at least 120mb. It seems to be tied to decoding speed, since reducing the decoding speed will slow down the memory leak. On pc it will rise until it hits some max cap, but on mobile it will crash when max memory is reached. Since my application should be scanning 24/7 it will crash eventually depending on timebetweenscans.

To Reproduce Steps to reproduce the behavior:

  1. Go to https://zxing-js.github.io/library/examples/qr-camera/
  2. Select decode continuously
  3. Hit start and check the starting memory footprint for the tab from chrome task manager
  4. Keep tab active and let the camera decode run for 15min - 1 hour
  5. check the memory footprint again.

Expected behavior When majorGc hits all memory is freed and memory does not keep increasing indefinitely

Screenshots memincrease This is after active for sometime.

Desktop: Browser Chrome, firefox

Smartphone (That tested crashes):

  • Device: samsung galaxy a40
  • OS: android 9
  • Browser: chrome

Additional context Since this seems to be related to amount of decode tries, i was thinking about the decodeContinuously() loop() but my knowledge ran out and cant really solve what is happening that is causing the memory to increase that is leading to crash.

urkku avatar Dec 31 '20 11:12 urkku

Could it be the console logging millions of tries in short time (the NotFoundException).

benjamincreativedk avatar Jan 06 '21 00:01 benjamincreativedk

Yes, it could also be a problem due to the recursive decode loop, but most probably because of the big number of exceptions.

odahcam avatar Jan 06 '21 04:01 odahcam

Bump, experiencing the same issue and the logging doesn’t seem to be the root cause. I programmatically remove all logs before building.

NoahGaeta avatar Mar 17 '21 21:03 NoahGaeta

Tested the example link with on PC with Chrome 107.0.5304.88 for 2 hours. Memory consumption 50-100Mb, changes back and forth.

rvalitov avatar Nov 03 '22 14:11 rvalitov