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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 memory problem?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
Voostra Posted - 03/29/2005 : 1:15:29 PM

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
1   L A T E S T    R E P L I E S    (Newest First)
Voostra Posted - 03/29/2005 : 1:52:36 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000