Good day @tech@zwo#44962,
We need buffer for pre process, and you can refer to NINA(open source) which has no problem through ASCOM.
I can easily make my 122-line program work by compiling it as a 64-bit application, to accept the 1GB of memory that your ASCOM driver needs for a single image. Unfortunately, it is not possible to switch PEMPro to 64-bit because it uses 32-bit DLLs to talk to some legacy hardware so it cannot run as a 64-bit application.
NINA uses WPF, but PEMPro was created over 18 years ago using Windows Forms, which is a predecessor to WPF. WPF has less memory limitations than Windows Forms. To change an application from WinForms to WPF would require a complete rewrite.
I noticed that the memory does not jump until the ASCOM client asks for the data. If the ZWO ASCOM driver needs memory for preprocessing, it could be disposed, or freed, before the final image is transmitted. Note that the exception in the code is happening within the ZWO ASCOM driver, not the 122-line application. It is unfortunate that your developers cannot find a way to use memory more efficiently in the ZWO ASCOM driver.
-Ray