Unmapped Memory Exception

Unmapped Memory Exception

Post by JERRYE » Wed, 15 Dec 1999 04:00:00



Unmapped Memory Exception?  I keep getting this error in my program.  What my
program does is create data files and then saves them.  It's like a database,
it allows you to load multiple data files and do searches on them.  I can load
some of the data files, but If I try to load to many, I get this error.  I
don't know what it means or how to even narrow it down.

Any help is appreciated
Jerry Evanoff

 
 
 

Unmapped Memory Exception

Post by JERRYE » Wed, 15 Dec 1999 04:00:00


Here is a little more detail.  I was able to trace it to this line:
pDatas[TotalData]->recordNum = NumRecords+(multipleGameCounter/nCtrls);

where pDatas is a structure containing a few things including the long
recordNum, when it crashes, TotalData = 1195.  pDatas is declared as:
*pDatas[Max_Data] where Max_Data = 12000.  The other numbers, NumRecords,
multipleGameCounter, nCtrls are just integers where, in this case, the result
turns out to be 136.

Hope this helps
Thanks
Jerry Evanoff

 
 
 

Unmapped Memory Exception

Post by Russell Zorne » Wed, 15 Dec 1999 04:00:00


Quote:> Here is a little more detail.  I was able to trace it to this line:
> pDatas[TotalData]->recordNum = NumRecords+(multipleGameCounter/nCtrls);

> where pDatas is a structure containing a few things including the long
> recordNum, when it crashes, TotalData = 1195.  pDatas is declared as:
> *pDatas[Max_Data] where Max_Data = 12000.  The other numbers, NumRecords,
> multipleGameCounter, nCtrls are just integers where, in this case, the result
> turns out to be 136.

What is in the pDatas array at index 1195? In other words what is the
pointer you are dereferencing in the statement pDatas[TotalData]->recordNum
when TotalData equals 1195? Chances are that pointer is off in never never
land. How do you fill this array with pointers in the first place?

Later,
-Russ

 
 
 

Unmapped Memory Exception

Post by Ludovic Nicoll » Wed, 15 Dec 1999 04:00:00




> Here is a little more detail.  I was able to trace it to this line:
> pDatas[TotalData]->recordNum = NumRecords+(multipleGameCounter/nCtrls);

> where pDatas is a structure containing a few things including the long
> recordNum, when it crashes, TotalData = 1195.  pDatas is declared as:
> *pDatas[Max_Data] where Max_Data = 12000.  The other numbers, NumRecords,
> multipleGameCounter, nCtrls are just integers where, in this case, the
> result
> turns out to be 136.

> Hope this helps
> Thanks
> Jerry Evanoff

I would like to see the actual code (in particular your array
declaration). The explanation below being a wild guess, don't blame me
if I am way out.

My current guess is that you allocated an array of length Max_Data of
*pointers* to your (guessed name) TData struct type.

This means you allocated an array to store pointers to the records  you
should have created somewhere else. Is it what you wanted to do? Since
you crash, I assume not and I assume you are using random valaues in the
array as pointers to your records. It crashed at that value, but it
could have crashed anywhere. ;-)

So, what you need to do is to declare your array as

TData pData[Max_Data]; if it is a static allocation
or
TData *pData; if it is dynamic allocation (within a routine), then
allocate your array in the heap with something like
pData = <dynamic_cast>(Ptr)NewPtrClear(Max_Data * sizeof(TData));
(Note that any allocation scheme like malloc would be fine here, I am
not debating this).

Note that you can't probably declare
TData pData[Max_Data] within a function, the compiler will likely tell
you that your stack allocation is larger than 32k, since your struct is
at least 4 bytes large and you have 12000 of them.

So, please let me know if my explanation has some relation with your
code. If not, I'll look at your code if you post it and apologize for
insulting you with too basic help ;-)

Ludo

 
 
 

Unmapped Memory Exception

Post by Wade William » Thu, 16 Dec 1999 04:00:00




> Here is a little more detail.  I was able to trace it to this line:
> pDatas[TotalData]->recordNum = NumRecords+(multipleGameCounter/nCtrls);

> where pDatas is a structure containing a few things including the long
> recordNum, when it crashes, TotalData = 1195.  pDatas is declared as:
> *pDatas[Max_Data] where Max_Data = 12000.  The other numbers, NumRecords,
> multipleGameCounter, nCtrls are just integers where, in this case, the
> result
> turns out to be 136.

When TotalData == 1195, pDatas[TotalData] must equal garbage.

Take a look at the values of pDatas[1192],pDatas[1193], pDatas[1194],
etc.  I think you'll find they contain addresses that are a consistent
number of bytes apart.  (This assumes that you allocated them all
together.  If you didn't, this very well may not apply)

For example, they might be 0x00A0BCDE, 0x00A0BCEA,0x00A0BCF6.  Those
addresses are 12 bytes apart, so pDatas[1195] should be 0x00A0BD02, but
you'll find that it's not - you'll probably find that it's utter
garbage, like 0xFFEEFFFF or some such.  (These addresses are totally
made up and yours will be totally different.  However, the consistency
should be there)

Wade

 ---------------------------------------------------------------------------
 Wade Williams                      "Put your message in a modem
 Systems Engineer, CCIE #3373        and throw it in the * Sea."
 Cisco Systems, Inc.                     - N. Peart
 Brentwood, TN                        
 615-221-2918                            

 ---------------------------------------------------------------------------