05-19-2023 03:30 PM
Here is LabVIEW code with error
During few minutes 32 bit LabVIEW reaches 4 GB memory limit and crashes. Here is error message of this test application:
Error message doesn't have any information about which vi brought crash. In real application Windows kills LabVIEW and its message doesn't have any sense. Unfortunately, it is hard to find such bugs.
Can LabVIEW be more helpful?
P.s. LabVIEW manual could be more helpful. In Unregister For Events Function: "National Instruments recommends that you unregister for events when you no longer need to handle them. If you do not unregister for events, LabVIEW continues to generate and queue the events as long as the VI runs, even if no Event structure is waiting to handle them, which consumes memory and can hang the VI if you enable front panel locking for the events." Crash isn't mentioned.
05-19-2023 03:54 PM - edited 05-19-2023 03:56 PM
The Reg Events should be done outside the loop. Here you are creating a new Event Registration Refnum every 10ms, which you never close. This will rapidly eat up RAM until LabVIEW crashes.
Here I put the Reg Events before the loop, and added an Unregister for Events after the loop:
Regards,
Raphaël.
05-19-2023 04:03 PM
i, specially(!), put inside because vi with such error are called multiply times.
05-19-2023 04:14 PM
If for whatever reason you want to put the "Register for Events" inside the loop, then you must put an "Unregister for Events" inside the loop as well. Each refnum opened in LabVIEW has to be closed with the appropriate function, without which there will be memory leaks. It is the same for VI references, queues, notifiers, etc …
05-19-2023 04:29 PM
Asked question -"Can LabVIEW be more helpful?"
05-20-2023 02:13 PM
@Vasilich2004 wrote:
i, specially(!), put inside because vi with such error are called multiply times.
I think you should tell us more about this. I can't think of a reason why I'd want to keep opening new references to the same event just to release them in the same case.
05-21-2023 06:43 PM
Please explain how your code is intended to work. It's crashing because you're blowing out your memory. Ok. How is your code intended to work? No, I'm not asking why did you do it that way? No, I just want to know how your code was intended to work.
Thank you.
05-21-2023 08:00 PM
There is an intend to show how easy LabVIEW could crash without any point on vi with error.
Hopefully, someone from NI reads about that.
05-22-2023 01:30 AM
@Vasilich2004 wrote:
There is an intend to show how easy LabVIEW could crash without any point on vi with error.
Hopefully, someone from NI reads about that.
I haven't the slightest clue what you are talking about. You can make any programming language crash easily if you want to.
05-22-2023 03:57 AM - edited 05-22-2023 03:57 AM
First, to solve the memory issue, i think this should be enough :
Now for your question."Can LabVIEW be more helpful?"
Well yes.. LabVIEW isn't perfect, getting a crash with a message that isn't helpful at all is very frustrating.
I have to say though, about 50% 20% of the time, if you copy past the crash message in google in find a forums post from someone with a similar issue and it give you a hint of where to dig.
I was a bit surprised/disappointed to not get a warning on this VI to say "hey, you have an event structure registering to a dynamic event, LabVIEW recommends to place an 'unregister node' somewhere, and by the way to learn more about caveats of dynamic event, make sure you read this white-paper : <insert useful link>"
Is NI going to put effort into making this more robust.. it would be nice, but I wouldn't hold my breath.
We have two ears and one mouth so that we can listen twice as much as we speak.
Epictetus