Memory leak fixes
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.
-
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 frommanagedPush
to indicate if the chunk was added to the heap or not. This MR hasmanagedPush
return a boolean to indicate whether or not the chunk was pushed onto the heap so that the calling methods can close the chunk'ssiafile
thread if it wasn't added to the heap. -
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'ssiafile
thread. - 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.