Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutOfMemoryException #44

Open
AdamoT opened this issue Mar 19, 2019 · 5 comments
Open

OutOfMemoryException #44

AdamoT opened this issue Mar 19, 2019 · 5 comments

Comments

@AdamoT
Copy link

AdamoT commented Mar 19, 2019

The issue is raised every time I leave my application running for about 3 days. I don't have a full stacktrace, because the exception is caught in AppDomain.CurrentDomain.UnhandledException but it's something like this:

2019-03-19 12:22:50.6656|ERROR|WindowsServiceClient.WindowsClient|Domain unhandled exceptionSystem.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos(IntPtr dataPtr, Predicate`1 processIdFilter)
   at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos(Predicate`1 processIdFilter)
   at System.Diagnostics.ProcessManager.GetProcessInfosCore(String machineName, Boolean isRemoteMachine)
   at System.Diagnostics.Process.GetProcesses(String machineName)
   at System.Diagnostics.Process.GetProcesses()
   at AudioSwitcher.AudioApi.CoreAudio.ProcessMonitor.ProcessTerminatedCheck(Object state)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback()
2019-03-19 12:22:26.2306|ERROR|WindowsServiceClient.WindowsClient|Domain unhandled exceptionSystem.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Collections.ArrayList.set_Capacity(Int32 value)
   at System.Collections.ArrayList.EnsureCapacity(Int32 min)
   at System.Collections.ArrayList.Add(Object value)
   at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos(IntPtr dataPtr, Predicate`1 processIdFilter)
   at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos(Predicate`1 processIdFilter)
   at System.Diagnostics.ProcessManager.GetProcessInfosCore(String machineName, Boolean isRemoteMachine)
   at System.Diagnostics.Process.GetProcesses(String machineName)
   at System.Diagnostics.Process.GetProcesses()
   at AudioSwitcher.AudioApi.CoreAudio.ProcessMonitor.ProcessTerminatedCheck(Object state)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback()
2019-03-19 12:22:50.6656|ERROR|WindowsServiceClient.WindowsClient|Domain unhandled exceptionSystem.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.String.CtorCharPtrStartLength(Char* ptr, Int32 startIndex, Int32 length)
   at System.Runtime.InteropServices.Marshal.PtrToStringUni(IntPtr ptr, Int32 len)
   at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos(IntPtr dataPtr, Predicate`1 processIdFilter)
   at System.Diagnostics.NtProcessInfoHelper.GetProcessInfos(Predicate`1 processIdFilter)
   at System.Diagnostics.ProcessManager.GetProcessInfosCore(String machineName, Boolean isRemoteMachine)
   at System.Diagnostics.Process.GetProcesses(String machineName)
   at System.Diagnostics.Process.GetProcesses()
   at AudioSwitcher.AudioApi.CoreAudio.ProcessMonitor.ProcessTerminatedCheck(Object state)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback()
2019-03-19 12:22:50.6656|ERROR|WindowsServiceClient.WindowsClient|Domain unhandled exceptionSystem.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown.
   at System.Linq.Set`1.Resize()
   at System.Linq.Set`1.Find(TElement value, Boolean add)
   at System.Linq.Enumerable.<ExceptIterator>d__73`1.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at AudioSwitcher.AudioApi.CoreAudio.ProcessMonitor.ProcessTerminatedCheck(Object state)
   at System.Threading.TimerQueueTimer.CallCallbackInContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.TimerQueueTimer.CallCallback()
   at System.Threading.TimerQueueTimer.Fire()
   at System.Threading.TimerQueue.FireNextTimers()
   at System.Threading.TimerQueue.AppDomainTimerCallback()

The system I'm running has 32GB of RAM and at the point when this exception is invoked I don't observe any huge system memory consumption.

@Azmarel
Copy link

Azmarel commented Apr 23, 2019

Hi, I have the same problem. Memory leak diagnosed with a profiler.

@alexandre-leites
Copy link

Have you guys moved to other lib or fixed it somehow?

@AdamoT
Copy link
Author

AdamoT commented Sep 14, 2020

Not really. The most important functionallity for me was to be able to get/change default system audio device, which is an undocumented windows feature and I haven't found any other lib that even attempts to implement it. If someone knows about one, please let me know. For now, I just restart my service when this issue happens

@Luckz
Copy link

Luckz commented Sep 15, 2020

The API as used by the 1.x GUI doesn't seem to have this problem, or doesn't trigger it, so perhaps it's a matter of using a specific working version?

@hvanzyll
Copy link

hvanzyll commented Oct 14, 2021

I have the same problem, it was only running a few hours

System.OutOfMemoryException
HResult=0x8007000E
Message=Array dimensions exceeded supported range.
Source=mscorlib
StackTrace:
at System.Collections.Generic.Dictionary2.Resize(Int32 newSize, Boolean forceNewHashCodes) at System.Collections.Generic.Dictionary2.Insert(TKey key, TValue value, Boolean add)
at System.Threading.Tasks.Task.AddToActiveTasks(Task task)
at System.Threading.Tasks.Task.ScheduleAndStart(Boolean needsProtection)
at System.Threading.Tasks.Task.InternalStartNew(Task creatingTask, Delegate action, Object state, CancellationToken cancellationToken, TaskScheduler scheduler, TaskCreationOptions options, InternalTaskOptions internalOptions, StackCrawlMark& stackMark)
at System.Threading.Tasks.TaskFactory.StartNew(Action action)
at AudioSwitcher.AudioApi.Observables.AsyncBroadcaster1.RaiseAllObserversAsync(Action1 observerAction)
at AudioSwitcher.AudioApi.CoreAudio.ProcessMonitor.ProcessTerminatedCheck(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.TimerQueueTimer.CallCallback()
at System.Threading.TimerQueueTimer.Fire()
at System.Threading.TimerQueue.FireNextTimers()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants