The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 memory problem?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Voostra

USA
Posts

Posted - 03/29/2005 :  1:15:29 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic

So, I seem to be getting a memory problem... Not sure what might cause it -

So far, the program opens a file, and scan through it taking some values out, copying them to a worksheet, then closes the stream. It then takes the min and max of a couple columns, and uses a GetN prompt to ask for some other values. Then, it generates a matrix to put the values into, and sizes it according to some of the input parameters. (Hadn't had any problems up to here).

I then wanted to 'zero' the matrix, so I put in a command to do this, and now I'm getting memory error messages:

"Can not allocate any more memory for _!_XB_N"

The last bit of the code regarding the matrix is here:

MatrixPage mp;
mp.Create("origin");
string newPageName3 = "data matrix";
PageBase pg3 = Project.Pages();
pg3.Rename(newPageName3);
MatrixLayer mly = mp.Layers(0);
Matrix matA(mly);

////properly dimension the matrix
mly.SetNumRows(matrixScanStep);
mly.SetNumCols(matrixMzStep);
matA.SetYMin(matrixScanMin);
matA.SetYMax(matrixScanMax);
matA.SetXMin(matrixMzMin);
matA.SetXMax(matrixMzMax);

matA = 0; //didn't have any problem until I put this in....


I'm suspicious I screwed up with the file opening closing somewhere, and it is sucking memory somehow, This is how I opened and closed the file:

string fileName = GetOpenBox("*.*"); // select a file to open
if( fileName.IsEmpty() )
{
out_str("No file was selected!");
return;
}

FILE *stream;
stream = fopen(fileName, "r" ); //open the file

//then,

while( !feof( stream ) )
{
if( fgets( line, 50, stream ) == NULL)
//exit
else
process the input lines
}
fclose( stream );

is there anything there I've buggered up?


If anyone can see where I might have goofed, it would be great!
I don't think it a problem with the data I'm processing - I'm writing it to work on large data files (1000's of point), but I'm testing it on a much smaller test data set of only ~20 points.


Thanks
Evan

Voostra

USA
Posts

Posted - 03/29/2005 :  1:52:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for putting up with me - I'm learning, slowly but surely...

I think I got it fixed - I think the problem was arising because I was trying to change all the values in a matrix of unspecified size (probably lots of values...)

I moved the
mly.SetNumRows(matrixScanStep);
mly.SetNumCols(matrixMzStep);

commands so they came after the MatrixLayer had been defined, but before I created the Matrix matA based on that layer, and it seems to have worked...

Does that make sense?

Edited by - Voostra on 03/29/2005 1:53:27 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000