Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Fatal internal error: "memory.cpp", line 593

I need some help.

Can some please explain what i am doing wrong here. i have created a Dll from a LV 7.0 vi. The header file looks something like this:

typedef struct {
long dimSize;
double elt[1];
} TD2;
typedef TD2 **TD2Hdl;

typedef struct {
double f0;
double df;
TD2Hdl magnitude;
} TD1;

void __cdecl Spectrum(double freq, double amp, TD1 *Spec);

And i have the following code where i allocate memory and attempt to call 'Spectrum':-

TD1 *Power;
double frequency=10, amplitude=1;
Power = (TD1 *) malloc(sizeof(TD1));
(*Power).magnitude = (TD2**)malloc(sizeof(TD2));
*(*Power).magnitude = (TD2*)malloc(5000*sizeof(TD2));

(*Power->magnitude)->dimSize = 5000;

for (i=0; i<500;
i++) {
(*Power->magnitude)->elt[i] = 0;
}

Spectrum(frequency, amplitude, Power);

I keep getting Fatal internal error: "memory.cpp", line 593" when it tries to call Spectrum. I believe i have allocated memory correctly although i may be wrong. (I was getting 'exception' errors before). The VI i used to create the Dll contains a basic 'Function Generator' (sine wave) and a 'Power Spectrum'.
I have looked at the Knowledge base and dll examples that come with LV 7.0 and have tried setCINArray and NumericArrayResize but have not had any luck. It seems like the documentation is for LV 6.0 and 6.1.

Has anybody seen this or have any idea why i am getting this?

Thanks
0 Kudos
Message 1 of 2
(3,191 Views)
Hello

To allocate memory for a LV data structure, you would need to use the LV memory manager functions, not malloc or delete. Refer to the "Using External Code in LV" manual for more information on these functions.

Or you might just try having another VI allocate the memory for you, and then pass that array to your spectrum function. That might be a little easier to setup.

Hope this helps

Bilal Durrani
NI
Bilal Durrani
NI
0 Kudos
Message 2 of 2
(3,191 Views)