andrewjjenkins / picsync

Sync Google Photos albums to a Nixplay Seed web picture frame
Apache License 2.0
18 stars 2 forks source link

Fix #2: Memory leak when uploading to Nixplay #3

Closed andrewjjenkins closed 2 years ago

andrewjjenkins commented 2 years ago

Problem: A memory leak occurs when uploading photos to Nixplay. For high-ish res photos (20Megapixel-ish), this is enough to grow past 512MB for the entire program after a few hundred photos (causing a pod with default parameters to be killed in GKE).

Solution: Pprof snapshots demonstrated the problem was in uploadS3 and related to the multipart MIME encoder.

There are two problems, both are fixed.

After this, the heap dump does not show growth without bound, even when uploading 50 pictures.

andrewjjenkins commented 2 years ago

Heap snapshot after uploading 47 photos shows that the leak is plugged. The photos were way more than 4MB combined; this leftover is probably internal cache / not-yet-GCable for the bytes buffer. out2-4