从调试器在 Windows CE 中运行导致最终内存不足崩溃
我正在为 Windows CE 机器构建 C# 应用程序。 CE 机器正在与串行设备通信,我正在使用 SerialPort 类。
当我通过右键单击并部署从 Visual Studio 运行该项目时,它将正常运行 15 到 20 分钟,然后减慢速度并最终因内存不足而崩溃,但是当我部署解决方案并从 CE 计算机本地运行它时(导航到该文件夹,打开exe),它运行一整天都很好,这是我尝试过的时间。
我不知道为什么。我尝试过构建发布和调试,但没有什么区别。唯一似乎是它从哪里逃走。我还尝试使用 dotTrace 分析应用程序,并且似乎在分析开始之前将其部署到 CE 计算机;无论如何,当探查器运行时我无法重现该错误。
我还尝试将处理串行流的代码打包到 DLL 中,认为 Visual Studio 在调试时可能会弄乱其中的某些内容,但这也没有改变任何东西。
我可以做些什么来提高 IDE 运行的稳定性吗?我喜欢能够用它进行调试,但这种不一致让我觉得我可能做错了什么。
I'm building a C# application for a Windows CE machine. The CE machine is talking to a serial device, and I'm using the SerialPort class.
When I run the project from Visual Studio by right-clicking and deploying, it will run fine for fifteen to twenty minutes before slowing down and eventually crashing from running out of memory, but when I deploy the solution and run it locally from the CE machine (navigate to the folder, open the exe), it runs fine for a whole day, which is as long as I've tried it.
I don't know why. I've tried building for release and debug, and it makes no difference. The only thing that seems to is where it's run from. I've also tried profiling the application using dotTrace, and it appears that it's being deployed to the CE machine before profiling starts; in any case, I can't reproduce the bug while the profiler is running.
I've also tried packaging the code that's handling the serial stream into a DLL, thinking that maybe Visual Studio was messing with something inside of it while debugging, but that didn't change anything, either.
Is there anything I can do to increase the stability of running from the IDE? I like being able to debug with it, but the inconsistency makes me feel like I might be doing something wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我们所知,我描述的问题与 System.IO.Ports 中的 SerialPort 类有关。我认为这可能与描述的一些问题有关 这里;托管 SerialPort 类调用循环内非托管的 WinAPI 代码,出现问题,并且非托管内存丢失。
As far as we've been able to tell, the problem I described is related to the SerialPort class from System.IO.Ports. I think it might be related to some of the problems described here; the managed SerialPort class calls into WinAPI code that's unmanaged inside of a loop, something goes wrong, and that unmanaged memory is lost.