Good morning. I’ve created an image acquisition system (on windows) using a Canon camera. Starting from the example code, I developed a container control that I add to a window at runtime. I establish the connection to the camera when the control opens and close it when it closes. The problem is that, occasionally and without any apparent pattern, the entire application crashes. I suspect that event handlers are remaining “alive” even as the various objects are being destroyed by the garbage collector. Does anyone have experience with this and could offer some suggestions?
These people could only speculate. Excerpts from your code might help here. ![]()
How do I insert my code? It’s split across dozens and dozens of points, so the error could be anywhere. Plus, the container control is being created and inserted into a massive application.![]()
Maybe you can replicate the issue in a sample project and share it with us?
(You can upload ZIP-Archives here)
Very, very complicated, but thanks. I’m hoping someone might be able to make some speculation
But I can imagine it is difficult.
You start by showing us the crashlog.
there is no a crashlog… the app closes instantaneously.
I might have found some cross-references between objects. But in that case, shouldn’t it crash every time? For me, it crashes sporadically, without any consistent pattern.
and it never crashes in debug mode, but only when running the compiled executable.
A sporadic crash can be the result of a race condition.
What do you see in Diagnostic Reports?
You can also check the Console for messages. Also you can let ChatGPT/Clause add instrumentation so that you can see where the crashes occur.
He is using Windows…
Has windows this DiagnosticReports?
Also you can let ChatGPT/Clause add instrumentation so that you can see where the crashes occur.
I really wouldn’t know how to go about this. In any case, I don’t know if this has solved the problem, but I have certainly eliminated an incorrect and dangerous situation: circular references between different objects.
I’ll keep you updated on the tests.
Crashed again; that’s not the issue ![]()
be sure every AddHandler have a RemoveHandler
set unused/old object properties/references to nil too
use System.DebugLog CurrentMethodName
check Runtime objects count
Forgetting to RemoveHandler shouldn’t cause a hard crash unless you add so many handlers you run out of memory. A missing handler (neglecting RemoveHandler) would net you a NilObjectException, not a crash.
Do you use some plugin?
Can you step through the code to find the line before the crash?
