LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Memory leak and problem with polymorh vi when calling vi from dll

Two problems appear for me when using the setup below.

 

First, I have a vi for opening a secondary vi:

 

vi1.png

 

Then I have a vi for calling the opened, secondary vi:

 

vi2.png

 

These two are compiled to a dll. The first one is called once, calling a function "open(char *)". The second one is called over and over, calling a function nextevent(double *, int). A simple example of an opened, secondary vi looks like this:

 

vi3.png

 

The code used to send data looks approximately like this:

 

 

dataout = malloc(dx->numelems * sizeof(double));
datain = (COMPLEX *) dx->cont;


for (i = 0; i < dx->numelems; ++i)
{
    dataout[cnt][i] = sqrt(datain[i].re * datain[i].re + datain[i].im * datain[i].im);
}

nextevent(dataout, dx->numelems);

free(dataout);

 

 

This code is called in a loop. dataout is a double array to be sent to the secondary vi, datain is the source data.

 

The problem now is that there is something eating up memory, and I fail to see why.

 

 

My second question is this:

 

vi4.png

 

 I want to insert a Hamming window, or some other form of windowing function. It doesn't work however, and the help tells me it is because a vi opened this way cannot contain any polymorphic vi. Is there a convenient way around this problem?

 

 

Lars Melander
Uppsala Database Laboratory, Uppsala University
0 Kudos
Message 1 of 5
(3,137 Views)

Regarding your second question:

As you say not possible to use a polymorphic vi in a DLL and in your case it is the windowing VI that is polymorphic. What you can do is to use only one instance of the windowing VI in the short cut menu. 

 

polymorphic select type.png

 

Here is a link to a report about this error in the knowledgeBase:

http://digital.ni.com/public.nsf/allkb/755CE99505A1C9FF8625693C00508DDE?OpenDocument

0 Kudos
Message 2 of 5
(3,122 Views)

Nope, doesn't work. I get an error when the vi is opened:

 

error.png

 

 

 

Lars Melander
Uppsala Database Laboratory, Uppsala University
0 Kudos
Message 3 of 5
(3,106 Views)

I was of course wrong about the memory leak. It looked like LabView caused it, but it was a leak that went undetected in our system, for some reason.

 

Apologies if anybody needlessly looked into this.

Lars Melander
Uppsala Database Laboratory, Uppsala University
0 Kudos
Message 4 of 5
(3,098 Views)

Nice that you got your first question sorted out.

 

Regarding the missing subvi: I have difficulty to reconstruct your error but it seems that you get passed the issue that you wrote in your first post. In that case I'm guessing the problem now lies in building of your dll. I think the following forum thread handles the same issue (based on the assumption that this is due to the building of the DLL.

 

http://forums.ni.com/t5/LabVIEW/Missing-subvi-from-ni-aalbase-lvlib/td-p/1031024

 

Does it help or am I wrong about the error message?

0 Kudos
Message 5 of 5
(3,092 Views)