Skip to content

Memory leak fixes

Matthew Sevey requested to merge memory-leak into unstable

In the scalability testing of 1.4.0 it was determined that there was a memory leak. Uploads and repairs would stop and downloads would stall.

Since a pointer to the siafile was added to the unfinishedUploadChunk there were some places in the repair code that were missing closing those files.

  1. managedPush doesn't always add chunks to the heap because it checks if the chunk is already in the heap or if it is being repaired. However nothing is returned from managedPush to indicate if the chunk was added to the heap or not. This MR has managedPush return a boolean to indicate whether or not the chunk was pushed onto the heap so that the calling methods can close the chunk's siafile thread if it wasn't added to the heap.
  2. managedPrepareNextChunk also would return with no error if there wasn't enough memory for the chunk. This MR returns an error so that the call method can close the chunk's siafile thread.
  3. The stuck loop only adds 1 chunk to the heap at a time, but builds all the unfinished chunks from file. This means that all the chunks not chosen by the stuck loop weren't getting closed properly. This MR addresses that and closes on the unneeded chunks from the stuck loop.

Merge request reports