System.OutOfMemoryException errors

Sonarr version (exact version): 2.0.0.4855
Mono version (if Sonarr is not running on Windows):
OS: Windows 10
((Debug logs)): https://pastebin.com/CLTeyGmz
(Make sure debug logging is enabled in settings and post the full log to hastebin/pastebin/dropbox/google drive or something similar, do not post them directly here)
Description of issue: Ever since the 2.0.0.4855 update, I’ve been getting these errors and after that error, Sonarr give me a message saying “All download clients are unavailable due to failures”. To rectify this, I have to restart Sonarr, then go into my Download Client (NZBget) and re-test it. Then it works again. I usually don’t get this error if I just let Sonarr be and do it’s normal stuff, but it happens whenever I have 5 or 6 TV shows added and downloaded.

Happen to be using Bit Defender?

It could be related to how it limits memory usage (also possible with another AV).

Using Windows Defender only. Sonarr is not crashing though, it just severs the connection between it and Nzbget

We’ll need to see ((trace logs)) that include the error to start. Not sure if @Taloth has any other suggestions.

@markus101 Going to be hard because turning on trace logs makes Sonarr incredibly slow to grab downloads, but I’ll try to reproduce the error with Trace logs on.

@markus101 Here’s from the Trace logs:
https://pastebin.com/BxkV91d0

A small update. I seem to be getting this error every morning now when I wake up, so it’s not just something that appears every time I add shows. Also, I used NZBGet 19.1-r2031 Testing, but have downgraded to 19.1 stable to see if there’s any difference. That didn’t do anything. I did use 19.1 stable with Sonarr 2.0.0.4753 and never had any problems.

That looks like a small portion of the trace log only.

It also threw an OutOfMemoryException trying to load the 1MB log file into memory. Either something is limiting the memory or there is possibly some corruption, running MemTest overnight would rule out the latter. Disabling any anti-virus/anti-malware software for a while and seeing if the same issue arises would be a good first step to see if they are affecting Sonarr.

Ok, disabling Windows Defender to see if the issue happens without it running.

@markus101 Still getting the error after disabling antivirus. What’s the MemTest you are referring to?

http://www.memtest86.com/

How about we first check the memory usage of both the system and the process?

Sounds good. Is there a way to check it over time?

perfmon, it’s a tool available in every windows setup. But you’ll need to google to know how to use it. :wink:

Nice! I’ve set it up. Let’s see what it can find.

Great, be sure to monitor both physical and virtual memory.

I’m monitoring these

@Taloth Ok I got 4 crashes at 17:35:04.0, 17:35:13.1, 17:35:35.3, 17:35:43.9
Here’s the perfmon log: http://www.filedropper.com/systemmonitorlog

Here’s from Sonarr Trace logs:
17-7-18 17:35:03.8|Trace|HttpClient|Req: [GET] https://nzbfinder.ws/getnzb/dfdf.nzb&i=43544&r=sdfsdf
17-7-18 17:35:03.8|Trace|ConfigService|Using default config value for ‘proxyenabled’ defaultValue:'False’
17-7-18 17:35:04.0|Trace|EventAggregator|Publishing ProviderStatusChangedEvent
17-7-18 17:35:04.0|Warn|DownloadMonitoringService|Unable to retrieve queue and history items from NZBGET

[v2.0.0.4855] System.OutOfMemoryException: Exception of type ‘System.OutOfMemoryException’ was thrown.
at System.IO.MemoryStream.set_Capacity(Int32 value)
at System.IO.MemoryStream.EnsureCapacity(Int32 value)
at System.IO.MemoryStream.Write(Byte[] buffer, Int32 offset, Int32 count)
at NzbDrone.Common.Extensions.StreamExtensions.ToBytes(Stream input) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Common\Extensions\StreamExtensions.cs:line 15
at NzbDrone.Common.Http.Dispatchers.ManagedHttpDispatcher.GetResponse(HttpRequest request, CookieContainer cookies) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Common\Http\Dispatchers\ManagedHttpDispatcher.cs:line 86
at NzbDrone.Common.Http.Dispatchers.FallbackHttpDispatcher.GetResponse(HttpRequest request, CookieContainer cookies) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Common\Http\Dispatchers\FallbackHttpDispatcher.cs:line 60
at NzbDrone.Common.Http.HttpClient.Execute(HttpRequest request) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Common\Http\HttpClient.cs:line 70
at NzbDrone.Core.Download.Clients.Nzbget.NzbgetProxy.ProcessRequest[T](NzbgetSettings settings, String method, Object[] parameters) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Download\Clients\Nzbget\NzbgetProxy.cs:line 232
at NzbDrone.Core.Download.Clients.Nzbget.NzbgetProxy.GetHistory(NzbgetSettings settings) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Download\Clients\Nzbget\NzbgetProxy.cs:line 135
at NzbDrone.Core.Download.Clients.Nzbget.Nzbget.GetHistory() in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Download\Clients\Nzbget\Nzbget.cs:line 112
at NzbDrone.Core.Download.Clients.Nzbget.Nzbget.GetItems() in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Download\Clients\Nzbget\Nzbget.cs:line 184
at NzbDrone.Core.Download.TrackedDownloads.DownloadMonitoringService.ProcessClientDownloads(IDownloadClient downloadClient) in M:\BuildAgent\work\b69c1fe19bfc2c38\src\NzbDrone.Core\Download\TrackedDownloads\DownloadMonitoringService.cs:line 89

17-7-18 17:35:04.0|Trace|ConfigService|Using default config value for ‘removecompleteddownloads’ defaultValue:'False’
17-7-18 17:35:04.0|Trace|EventAggregator|Publishing TrackedDownloadRefreshedEvent
17-7-18 17:35:04.0|Trace|EventAggregator|TrackedDownloadRefreshedEvent -> QueueService
17-7-18 17:35:04.0|Trace|EventAggregator|Publishing QueueUpdatedEvent
17-7-18 17:35:04.0|Trace|EventAggregator|QueueUpdatedEvent -> QueueModule
17-7-18 17:35:04.0|Trace|EventAggregator|QueueUpdatedEvent <- QueueModule
17-7-18 17:35:04.0|Trace|EventAggregator|TrackedDownloadRefreshedEvent <- QueueService
17-7-18 17:35:04.0|Trace|CommandQueueManager|Updating command status
17-7-18 17:35:04.0|Trace|EventAggregator|Publishing HealthCheckCompleteEvent
17-7-18 17:35:04.0|Trace|EventAggregator|HealthCheckCompleteEvent -> HealthModule
17-7-18 17:35:04.0|Trace|EventAggregator|HealthCheckCompleteEvent <- HealthModule
17-7-18 17:35:04.0|Trace|EventAggregator|Publishing CommandExecutedEvent
17-7-18 17:35:04.0|Trace|EventAggregator|CommandExecutedEvent -> TaskManager
17-7-18 17:35:04.0|Trace|TaskManager|Updating last run time for: NzbDrone.Core.Download.CheckForFinishedDownloadCommand
17-7-18 17:35:04.0|Trace|Http|Req: 556 [GET] /api/queue?sort_by=timeleft&order=asc
17-7-18 17:35:04.0|Trace|Http|Res: 556 [GET] /api/queue?sort_by=timeleft&order=asc: 200.OK (5 ms)
17-7-18 17:35:04.0|Trace|EventAggregator|CommandExecutedEvent <- TaskManager
17-7-18 17:35:04.0|Trace|EventAggregator|CommandExecutedEvent -> TaskModule
17-7-18 17:35:04.0|Trace|EventAggregator|CommandExecutedEvent <- TaskModule
17-7-18 17:35:04.0|Debug|Api|[GET] /api/queue?sort_by=timeleft&order=asc: 200.OK (5 ms)
17-7-18 17:35:04.0|Trace|Http|Req: 557 [GET] /api/health
17-7-18 17:35:04.0|Trace|CommandExecutor|CheckForFinishedDownloadCommand <- DownloadMonitoringService [00:00:03.0004110]
17-7-18 17:35:04.0|Trace|Http|Res: 557 [GET] /api/health: 200.OK (3 ms)
17-7-18 17:35:04.0|Debug|Api|[GET] /api/health: 200.OK (3 ms)

The memory usage is quite high, but at 17:35 it’s not high enough to crash, unless there’s a lot of virtual memory fragmentation.

Task Manager->Details->right click on NzbDrone->Create Dump.

Zip that up and get it to me. Be warned, the unzipped dump file is gonna be ~1800 MB, so definitely zip it.

Edit: And put a good password on it and PM it to me, coz that dump is potentially gonna be littered with privacy sensitive info.

I restarted Sonarr when I got that error. Do I need to recreate the error before I create the dump?