Out of memory error saving live stack preview

A place to report problems and bugs in SharpCap
Forum rules
‍

If you have a problem or question, please check the FAQ to see if it already has an answer : https://www.sharpcap.co.uk/sharpcap-faqs

Please also read about Troubleshooting USB Issues before posting.

*** Please do not post license keys - please report any problems with licensing to 'admin' by private message ***

Please include the following details in any bug report:

* Version of SharpCap
* Camera and other hardware being user
* Operating system version
* Contents of the SharpCap log after the problem has occurred.
[If SharpCap crashes, please send the bug report when prompted instead of including the log]
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Out of memory error saving live stack preview

#1

Post by lowenthalm »

After updating from 4.1.13584.0-64bit to 4.1.14130.0-64bit last week, I started getting out of memory errors after about 8 hours of capturing images using live stacking (saving RAWS as fits and livestack histogram preview pngs). This happened both times I captured at bin1x1 all night, and neither of the two times I was capturing bin2x2 all night (10 hours). It always crashed at the point it was trying to execute either "Save current live stack (FITSRawStack32Bit)" or "Save current live stack (PNGWithStretch)" in my capture script. Given bin 1 vs bin 2 behaviour, it seems to be sensitive the size of the images involved.

At first I thought this was similar to the previously reported bug, that just got fixed in the Jan 26 release, but the log of that bug doesn't show any out of memory issues.

Each loop of my image capturing sequencer script was live stacking 2 three minute exposures, saving the raw images of these during live stacking, and then saving an RGB fits of the 2 exposure stack as a fits and also a PNG with stretch of the stack, reseting the stack and starting again. After the first exposure of the each live-stack is captured, I am also doing a plate solve of the first live stacked image with Python code to make sure the dithering between live stack loops hasn't drifted me too far away from the original target.

I have plenty of disk space, and I Windows seems to have enough memory remaining when I look at the error on screen a couple hours after it happens (when I wake up!)

Let me know if you need to see the more of the logs below...

Below are snips of the errors:

Code: Select all

Debug   02:47:59.409663 #1  Sequencer : Starting  : Save current live stack (FITSRawStack32Bit)                                                     in void SharpCap.Sequencer.SequencerContext.OnStepStart(ISequencerStep step, bool excludeFromProgressCalcs)
Info    02:47:59.696613 #1  Initializing FitsFileWriter at 4552x3032x3x0bits, RGB, 4 bytes per PEL for ZWO ASI2400MC Pro                            in void SharpCap.Base.FileWriters.FileWriterBase.Initialize(IFileNameProvider fnp, ColourSpaceId colourSpaceId, int width, int height, int bytesPerPixelElement, int significantBitDepth, int colourPlanes, string DeviceName)
Debug   02:47:59.711472 #1  Failed to allocate buffer of category Unpooled                                                                          in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   02:47:59.711796 #1  Dumping memory because: Failing to allocated 157.95 MB for a buffer                                                     in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   02:47:59.712121 #1  GC Memory 1.02 GB                                                                                                       in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   02:47:59.716364 #1  Process Memory 6.50 GB                                                                                                  in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   02:47:59.719631 #1  Total Physical Memory 7.98 GB                                                                                           in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   02:47:59.719871 #1  Available Physical Memory 1.03 GB                                                                                       in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Info    02:47:59.722338 #1  Allocator is using VirtualAlloc                                                                                         in void SharpCap.Base.Memory.Allocator.DumpStatus()
Info    02:47:59.731688 #1  Buffer info for category Pooled                                                                                         in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.739517 #1  Total memory size in category : 939.045MB                                                                               in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.743939 #1  26 buffers of size 12271512, totalling 304.000MB                                                                        in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.744546 #1  4 buffers of size 49086048, totalling 187.000MB                                                                         in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.744848 #1  17 buffers of size 27603328, totalling 447.000MB                                                                        in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.746046 #1  Buffer info for category Unpooled                                                                                       in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.746634 #1  Total memory size in category : 137.475MB                                                                               in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.747154 #1  1 buffers of size 6135756, totalling 5.000MB                                                                            in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.747488 #1  2 buffers of size 27603328, totalling 52.000MB                                                                          in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.747849 #1  1 buffers of size 82809984, totalling 78.000MB                                                                          in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.748233 #1  1 buffers of size 882, totalling 0.000MB                                                                                in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.748590 #1  Buffer info for category External                                                                                       in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.749712 #1  Total memory size in category : 0.000MB                                                                                 in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    02:47:59.757414 #1  BufferFrame (4552x3032, RGB, BitDepth=16, ColorPlanes=3, EffectiveBitDepth=16, BytesPerPixel=6, Binning=1x1 Index=5394 LiveStackDisplayFrame                    in void SharpCap.Base.BufferFrame.DumpDebug()
Info    02:47:59.758763 #1  Memory 82809984 bytes (78.97 MB) : Unpooled                                                                             in void SharpCap.Base.BufferFrame.DumpDebug()
and the second one:

Code: Select all

Debug   03:26:01.499291 #1  Sequencer : Starting  : Save current live stack (FITSRawStack32Bit)                                                     in void SharpCap.Sequencer.SequencerContext.OnStepStart(ISequencerStep step, bool excludeFromProgressCalcs)
Info    03:26:01.603776 #1  Initializing FitsFileWriter at 4552x3032x3x0bits, RGB, 4 bytes per PEL for ZWO ASI2400MC Pro                            in ICaptureFileWriter SharpCap.FrameTransforms.LiveStacking.LiveStackSaveManager.CreateWriter(int bitDepth, bool autoSave, string toFilename, FrameInfo info)
Info    03:26:03.413398 #1  Writing capture settings file to \\Mac\Home\Desktop\SharpCap Captures\2026-01-25\NGC3726\03_22_52(NoFilter)\NGC3726@2026-01-25T11_22_52Z-11_25_51Z_32b_2fr_360s.CameraSettings.txt          in void SharpCap.Models.Camera.WriteCaptureSettingsTextAndHistogram(bool writeHistogram, string filename, string contents)
Debug   03:26:03.415761 #1  Notification (Status=OK): Stack saved to \\Mac\Home\Desktop\SharpCap Captures\2026-01-25\NGC3726\03_22_52(NoFilter)\NGC3726@2026-01-25T11_22_52Z-11_25_51Z_32b_2fr_360s.fits                    in void SharpCap.UI.NotificationViewModel.DisplayMessage(NotificationMessage message)
Debug   03:26:03.417955 #1  Sequencer : Completed : Save current live stack (FITSRawStack32Bit)                                                     in void SharpCap.Sequencer.SequencerContext.OnStepEnd(ISequencerStep step, bool excludeFromProgressCalcs)
Debug   03:26:03.532658 #1  Sequencer : Starting  : Save current live stack (PNGWithStretch)                                                        in void SharpCap.Sequencer.SequencerContext.OnStepStart(ISequencerStep step, bool excludeFromProgressCalcs)
Warning 03:26:03.877051 #39 Possible dispatcher overload/UI Freeze. Background priority not run for 11.0s since 11:25:52 AM. Dispatcher queue length is 48, currently 1 in progress. Dispatcher disable count : 0                   in async Task SharpCap.UISwitcher+DispatcherWatchDog.MonitorDispatcher()
Debug   03:26:03.877173 #39 Attempting to dump diagnostic thread state                                                                              in string[] SharpCap.Base.ThreadDumper.GetThreadStacks()
Error   03:26:03.935265 #1  Out of memory error within OpenCV : Exception of type 'OutOfMemoryException' : bad allocation error in OpenCV (AdjustSaturation) 
Stack Trace:   at object SharpCap.Base.OpenCVFrameExtensions+ResultWrapper.GetResult() in C:/Documents/Source Code/SharpCap4.1/src/SharpCap.Base/OpenCVInterop.cs:line 144
   at T SharpCap.Base.OpenCVFrameExtensions+TypedResultWrapper<T>.GetResult() in C:/Documents/Source Code/SharpCap4.1/src/SharpCap.Base/OpenCVInterop.cs:line 187
   at TRet SharpCap.Base.OpenCVFrameExtensions+ActionRunner<TRet, TInter, TParser>.RunActionWithErrorHandling(INeedToLogParams needToLogParameters, string action, Action<ResultData> func)                   in TRet SharpCap.Base.OpenCVFrameExtensions+ActionRunner<TRet, TInter, TParser>.Run<T1>(Action<ResultData, FrameWrapper, T1> func, string action, FrameWrapper targetFrame, T1 param1)
Debug   03:26:03.937939 #1  Failed to allocate buffer of category Unknown                                                                           in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   03:26:03.938064 #1  Dumping memory because: OpenCV failed to create matrix                                                                  in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   03:26:03.939445 #1  GC Memory 878.89 MB                                                                                                     in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   03:26:03.940674 #1  Process Memory 7.27 GB                                                                                                  in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   03:26:03.943356 #1  Total Physical Memory 7.98 GB                                                                                           in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Debug   03:26:03.943564 #1  Available Physical Memory 930.89 MB                                                                                     in void SharpCap.Base.Memory.MemoryDiagnostics.Dump(BufferCategory falureCategory, string reason)
Warning 03:26:03.943745 #39 Unexpected Pss function error, cannot create snapshot : Exception of type 'InvalidOperationException' : Could not create snapshot to process. Error 1455. 
Stack Trace:   at new Microsoft.Diagnostics.Runtime.WindowsProcessDataReader(int processId, WindowsProcessDataReaderMode mode)
   at DataTarget SharpCap.Base.ThreadDumper.CreateSnapshot(int pid) in C:/Documents/Source Code/SharpCap4.1/src/SharpCap.Base/ThreadDumper.cs:line 211              in string[] SharpCap.Base.ThreadDumper.GetThreadStacks()
Info    03:26:03.943859 #39 Current thread status:                                                                                                  in void SharpCap.Watchdog.DumpThreadStacks()
Info    03:26:03.943926 #39                                                                                                                         in void SharpCap.Watchdog.DumpThreadStacks()
Info    03:26:03.944259 #1  Allocator is using VirtualAlloc                                                                                         in void SharpCap.Base.Memory.Allocator.DumpStatus()
Info    03:26:03.949596 #1  Buffer info for category Pooled                                                                                         in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.955929 #1  Total memory size in category : 1187.727MB                                                                              in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.957107 #1  33 buffers of size 12271512, totalling 386.000MB                                                                        in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.957321 #1  7 buffers of size 49086048, totalling 327.000MB                                                                         in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.957443 #1  18 buffers of size 27603328, totalling 473.000MB                                                                        in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.957799 #1  Buffer info for category Unpooled                                                                                       in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.957951 #1  Total memory size in category : 222.301MB                                                                               in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.958142 #1  2 buffers of size 6135756, totalling 11.000MB                                                                           in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.958261 #1  2 buffers of size 27603328, totalling 52.000MB                                                                          in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.958377 #1  2 buffers of size 82809984, totalling 157.000MB                                                                         in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.958494 #1  1 buffers of size 882, totalling 0.000MB                                                                                in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.958634 #1  Buffer info for category External                                                                                       in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.959931 #1  Total memory size in category : 0.000MB                                                                                 in void SharpCap.Base.Memory.BufferMonitor.LogAndWrite(string message, TextWriter writer)
Info    03:26:03.962263 #1  BufferFrame (4552x3032, RGB, BitDepth=16, ColorPlanes=3, EffectiveBitDepth=14, BytesPerPixel=6, Binning=0x0 Index=6158 LiveStackReget                   in void SharpCap.Base.BufferFrame.DumpDebug()
Info    03:26:03.962692 #1  Memory 82809984 bytes (78.97 MB) : Unpooled                                                                             in void SharpCap.Base.BufferFrame.DumpDebug()
User avatar
admin
Site Admin
Posts: 17510
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Out of memory error saving live stack preview

#2

Post by admin »

Hi,

can you send me the full log please? From the snippets, It looks like there is a memory leak, hopefully the full log will give me some ideas of what is causing it and where to look.

cheers,

Robin
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Re: Out of memory error saving live stack preview

#3

Post by lowenthalm »

OK. That was my suspicion. It seemed like maybe it was running out of graphics memory due to an issue in the PNG writer.

I have attached the sharpcap logs and sequence logs for each, as well as two the code for two python objects that get called by the sequence code to check for guidance dithering drifting too far from the original target. This exercises the plate solver code a lot (I have it setup for using ASTAP still - just haven't gotten around switching to SC native plate solver yet), plate solving the first image of the live stack after a dither has occurred.

The python methods called by my capture seqeunce that give the plate solve engine a workout (lots of downsampled PNG generation to pass to ASTAP) are:

in LiveCaptureGuidance Class.py to do the plate solve for drift check from python code:
MDLLiveCaptureGuidance.CheckDrift( ... )
calling self.PlateSolveFirstFrameOK( ... )
calling MDLGuidanceAssistant.GuidanceError_PlateSolveCode( ... ) in GuidanceAssistant.py

In both the cases of failure capturing bin1x1 data, I estimate over the 8 hours capture time, the as many as 120 plate solves were performed to check for drift check. This was once every other 3 minute image, as that was how often I did dithers.

I will start attachments with the pertinent python scripts and sequence logs, as they are small. The SharpCap logs are huge at over 20mb due to including entire large sequence scripts every time I branch in my sequences by throwing an exception in Python - which I do a lot. The compressed files are also nearly 3mb. I will split the logs into segments so I can post them in multiple posts.
Attachments
Sequence log terminated with error at 247a.txt.zip
(79.07 KiB) Downloaded 4 times
Sequence log when out of memory at 0325a.txt.zip
(76.15 KiB) Downloaded 4 times
GuidanceAssistant.py
(27.86 KiB) Downloaded 3 times
LiveCaptureGuidance Class.py
(36.78 KiB) Downloaded 6 times
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Re: Out of memory error saving live stack preview

#4

Post by lowenthalm »

2026-01-22 SharpCap log part 1
Attachments
SharpCap log terminated with error at 247a PART1.txt.zip
(930.13 KiB) Downloaded 3 times
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Re: Out of memory error saving live stack preview

#5

Post by lowenthalm »

2026-01-22 SharpCap log part 2
Attachments
SharpCap log terminated with error at 247a PART2.txt.zip
(972.65 KiB) Downloaded 2 times
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Re: Out of memory error saving live stack preview

#6

Post by lowenthalm »

2026-01-22 SharpCap log part 3
Attachments
SharpCap log terminated with error at 247a PART3.txt.zip
(842.61 KiB) Downloaded 3 times
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Re: Out of memory error saving live stack preview

#7

Post by lowenthalm »

2026-01-25 SharpCapLog Part 1
Attachments
2026-01-25 SharpCapLog out of memory at 0325a Part 1.txt.zip
(975.01 KiB) Downloaded 3 times
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Re: Out of memory error saving live stack preview

#8

Post by lowenthalm »

2026-01-25 SharpCapLog Part 2
Attachments
2026-01-25 SharpCapLog out of memory at 0325a Part 2.txt.zip
(949.07 KiB) Downloaded 3 times
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Re: Out of memory error saving live stack preview

#9

Post by lowenthalm »

2026-01-25 SharpCapLog Part 3
Attachments
2026-01-25 SharpCapLog out of memory at 0325a Part 3.txt.zip
(865.46 KiB) Downloaded 4 times
lowenthalm
Posts: 224
Joined: Mon May 07, 2018 12:27 am

Re: Out of memory error saving live stack preview

#10

Post by lowenthalm »

2026-01-25 SharpCapLog Part 4
Attachments
2026-01-25 SharpCapLog out of memory at 0325a Part 4.txt.zip
(186.08 KiB) Downloaded 4 times
Post Reply