From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Fatal internal error: "memory.cpp" line 638

I tried posting this yesterday but got no response so i thought i would try again.


I have created a dll (C++) from a labview vi (7.1.1 WinXP) that does order analysis. However when i try to use this

dll i keep getting this memory error. I believe i am allocating memory correctly (i.e. i am using DSNewHandle and

DSSetHandleSize etc).

I have seen other messages that claim that this error is caused by the "Type cast" function in LV. I don't use the

"Type cast" function in my vi specifically (attached) however it is in some of the NI vi's that i use for order

analysis (e.g. New Gabor Refnum.vi). The actual Labview code (i.e. the Labview vi that i used to create the dll)

does not give me this error when i run it. It only occurs when i run the dll.

I have also attached the build file that i used to create the dll and i have pasted my c++ code to verify that i am

allocating memory correctly.

Thanks

long PulsesPerRev=0, *pDataSize, ErrorCode=0, Size=0, Speedlen, Timelen;
double SampleRate=0, Value, MinOrder=0, MaxOrder=0, OrderResolution=0;
double RpmOffset=0, RpmMult=0, QntOffset=0, QntMult=0, OrdOffset=0, OrdMult=0;

float VibValue, TachValue, SpeedProfileRPM, SpeedProfileTime;

int32 i=0, j=0, k=0;

unsigned long iWindowType,iActWinType=0;
long iWindowLength, iActWinLen=0;

int iInstance, NumofSamples=80000, nrows =2000, ncols = 2000;

TD1Hdl HdlData, HdlTach;
TD2 InputWinInfo, ActualWinInfo;
TD3 OrderRange;
TD4Hdl HdlSpecMap; //Spec Map (intensity plot data)
TD5Hdl HdlSpeed, HdlTime;
TD6 RpmScale, OrdScale, QntInfo;

// Set values
InputWinInfo.windowLength = iWindowLength;
InputWinInfo.windowType = iWindowType;
// Set values
ActualWinInfo.windowLength = iActWinLen;
ActualWinInfo.windowType = iActWinType;

// Set values
OrderRange.MinOrder = MinOrder;
OrderRange.MaxOrder = MaxOrder;
OrderRange.Resolution = OrderResolution;

OrdScale.multiplier = OrdMult;
OrdScale.offset = OrdOffset;
RpmScale.multiplier = RpmMult;
RpmScale.offset = RpmOffset;
QntInfo.multiplier = QntMult;
QntInfo.offset = QntOffset;

// Allocate memory for spectral Map
HdlSpecMap = (TD4Hdl) DSNewHandle(sizeof(TD4Hdl));
error = DSSetHandleSize(HdlSpecMap, sizeof(long)*2 + nrows*ncols*sizeof(double) );

if (error != mFullErr && error != mZoneErr)
{
(*HdlSpecMap)->dimSizes[0] = nrows;
(*HdlSpecMap)->dimSizes[1] = ncols;
}
else {
AfxMessageBox("Unable to allocate memory");
}

// Allocate memory for speed profile arrays
HdlData = (TD1Hdl) DSNewHandle(sizeof(TD1Hdl));
error = DSSetHandleSize(HdlData, sizeof(long) + NumofSamples*sizeof(double) );

HdlTach = (TD1Hdl) DSNewHandle(sizeof(TD1Hdl));
error = DSSetHandleSize(HdlTach, sizeof(long) + NumofSamples*sizeof(double) );

Speedlen = 5000;
Timelen = 5000;
// Allocate memory for Vibration Data and Tach Data
HdlTime = (TD5Hdl) DSNewHandle(sizeof(TD5Hdl));
error = DSSetHandleSize(HdlTime, sizeof(long) + Timelen*sizeof(double) );

HdlSpeed = (TD5Hdl) DSNewHandle(sizeof(TD5Hdl));
error = DSSetHandleSize(HdlSpeed, sizeof(long) + Speedlen*sizeof(double) );

// Alocate memory for data size
pDataSize = (long *) DSNewPtr(sizeof(long));

// Read in Data from file
FILE *stream;
char line[100];

stream=fopen( "C:\\OrderAnalysis.txt", "r" );

while (fgets( line, 100, stream ) != NULL)
{
sscanf( line, "%f %f",&VibValue, &TachValue);
(*HdlTach)->elt[i] = TachValue;
(*HdlData)->elt[i] = VibValue;
i++;
}
fclose(stream);

(*HdlTach)->dimSize = i;
(*HdlData)->dimSize = i;

OrderAnalysis(&HdlData, &HdlTach,
&InputWinInfo, SampleRate, PulsesPerRev,
&OrderRange, &ActualWinInfo, &HdlSpecMap, &HdlSpeed,
&HdlTime, &RpmScale, &OrdScale,
&QntInfo, pDataSize);
0 Kudos
Message 1 of 2
(2,463 Views)
Please see responses to this post here.
0 Kudos
Message 2 of 2
(2,443 Views)