Jump to content

External memory allocation and management using C


Recommended Posts

If I pass a buffer of anything to CIN/DLL on one terminal and return a to the buffer handle on another terminal, LabVIEW doesn't autodispose the buffer now that it is no longer used on block diagram? I've to verify this also since this is a different case from the one you rolf answered.

It's not exactly clear what you try to do? If I understand you correctly, you want to pass in a LabVIEW data wire into a DLL Node and not wire the right side of that terminal, but instead have the DLL pass that same handle through another terminal back to the diagram This is not only gonna create a memory leak but also crash too, sooner or later.

The reason is as follows: If you wire in something to the left side of a terminal pair in a DLL Node and not wire the right side, LabVIEW has to assume that the data is not used anymore and dispose of it. This would make the handle you return through another terminal invalid. At the same time if you do not wire anything to the left side of a terminal pair LabVIEW will allocate the default data (for instance an empty array) for the specified datatype to pass to the DLL but since you overwrite it with the now invalid handle inside the DLL you loose that handle.

This is all logical when you follow the rule that whoever allocates memory should be concerned about disposing of it. In this case LabVIEW did allocate the memory in the diagram to pass to the DLL and also is responsible to dispose of it after the diagram does not seem to use it anymore.

If you try to do magic behind LabVIEWs back inside the DLL you have to be EXTREMELY careful what you do. In most cases it is not worth the trouble to even try to do such things.

Rolf Kalbermatter

Link to comment
This is all logical when you follow the rule that whoever allocates memory should be concerned about disposing of it. In this case LabVIEW did allocate the memory in the diagram to pass to the DLL and also is responsible to dispose of it after the diagram does not seem to use it anymore.

This is what I thought. Then I'll stick with my queue version of polymorphic datatype.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.