This site is no longer active and is available for archival purposes only. Registration and login is disabled.

running out of memory ?


running out of memory ?

Postby Conan » Nov 3, 2002 @ 5:56pm

I have some structs with a few __int8 variables and a TCHAR[20]. When I try to create large numbers of these ( say 1000 or more ) the game hangs but lower numbers such as 500 work fine.

Each of these struct items is only 50 bytes so creating 1000 should only utilise 50Kb

Is there a way to test for lack of memory? My iPaq has a good amount of ram before running the game with just under 10Mb free for program and similar for storage.

I'm also trying to see if I'm just making a coding mistake somewhere and checking where it goes wrong in the debugger.
What is Best in Life ?
User avatar
Conan
pm Member
 
Posts: 1309
Joined: Dec 24, 2001 @ 5:16am
Location: the Shades, Ankh-Morpock


Postby BurningSheep » Nov 3, 2002 @ 6:31pm

Do you want custom Snails levels? Click
User avatar
BurningSheep
pm Insider
 
Posts: 1226
Joined: Apr 12, 2002 @ 11:49pm
Location: The Netherlands


Postby MirekCz » Nov 3, 2002 @ 6:36pm

With best regards,
Mirek Czerwinski
User avatar
MirekCz
pm Member
 
Posts: 269
Joined: Sep 18, 2001 @ 6:42pm
Location: Poland,city Poznań


Postby Conan » Nov 3, 2002 @ 6:38pm

I was not making use of new so I will try shortly. Currently here's what I am doing. This is in among all my other variable definitions none of which use new
:-
//struct definition
struct planet_data
{
__int8 p_octant;
__int8 p_sector;
__int8 p_race;
__int8 p_class;
__int8 p_techno;
__int8 p_civtype;
__int8 p_sysno;
__int8 p_sundist;
__int8 p_orbit
TCHAR p_name[20];
} planets[2000];

UPDATE: Yes, that works fine now as far as allocating the structs but now I cannot access the structs from functions as they are now created in PF's init function???. I am not understanding what PF requires of me obviously.
I tried defining the struct as follows:-

after the struct is defined I added
planet_data *planets and in the PF init I put
planet_data *planets = new planet_data[2000];
This builds but the game crashes so I'm still doing it wrong :(

I will transfer to the PocketFrog board now as this is not a general problem anymore. I can't define the variable using new within the only place in PF where I can define variables so the whole game can access them ???
Last edited by Conan on Nov 3, 2002 @ 7:11pm, edited 1 time in total.
What is Best in Life ?
User avatar
Conan
pm Member
 
Posts: 1309
Joined: Dec 24, 2001 @ 5:16am
Location: the Shades, Ankh-Morpock


Postby Digby » Nov 3, 2002 @ 7:11pm

You're almost certainly blowing out your stack. The stack limit for your application is set by a linker switch - /STACK:reserve[,commit]. The default set for a project using EVC 3.0 is /STACK:0x10000,0x1000. That's 64K max.
Digby
pm Insider
 
Posts: 1011
Joined: Apr 29, 2001 @ 1:53pm


Postby BurningSheep » Nov 3, 2002 @ 7:15pm

Do you want custom Snails levels? Click
User avatar
BurningSheep
pm Insider
 
Posts: 1226
Joined: Apr 12, 2002 @ 11:49pm
Location: The Netherlands


where to allocate

Postby Conan » Nov 3, 2002 @ 7:33pm

BurningSheep, re your last reply that's what I tried but it crashed with an illegal operation. It may be that I just made a mistake so I will look again. I assumed that the definition within the class definition was not correctly tying up with the init's allocation

Update: My allocation statements were wrong. I checked against your syntax and it all works now. Many thanks for your help. ( every time I meet a new area I get bogged down in syntax. The lack of good examples in the online help means that I don't always see how to do things )
What is Best in Life ?
User avatar
Conan
pm Member
 
Posts: 1309
Joined: Dec 24, 2001 @ 5:16am
Location: the Shades, Ankh-Morpock


Postby Kzinti » Nov 3, 2002 @ 10:28pm

Kzinti
pm Member
 
Posts: 3238
Joined: Jan 13, 2002 @ 5:23am


c++ documentation

Postby Conan » Nov 4, 2002 @ 12:20am

What is Best in Life ?
User avatar
Conan
pm Member
 
Posts: 1309
Joined: Dec 24, 2001 @ 5:16am
Location: the Shades, Ankh-Morpock


Postby Kzinti » Nov 4, 2002 @ 1:40am

I can understand where you are coming from. There is indeed quite a big hurdle to learning C++. It is close to the machine and definitely not user-friendly.

I myself started with assembler on my old CoCo 2 (a 6809 processor). I then moved to Pascal which as a much nicer syntax then C or C++. I then moved on to C and then C++. I had to chance to learn programming one thing at a time. I'm glad I didn't started with C++ from scratch.
Kzinti
pm Member
 
Posts: 3238
Joined: Jan 13, 2002 @ 5:23am


Postby Dan East » Nov 4, 2002 @ 2:06am

Like Digby said, you are definitely running out of stack space. Typically for larger arrays you allocate them dynamically with new or malloc.

Dan East
User avatar
Dan East
Site Admin
 
Posts: 5264
Joined: Jan 25, 2001 @ 5:19pm
Location: Virginia, USA


Postby DillRye » Nov 7, 2002 @ 3:55am

User avatar
DillRye
pm Insider
 
Posts: 477
Joined: Apr 25, 2002 @ 7:28am
Location: Iowa State University of Eng


Return to Windows Mobile


Sort


Forum Description

A discussion forum for mobile device developers on the Windows Mobile platform. Any platform specific topics are welcome.

Moderators:

Dan East, sponge, Digby, David Horn, Kevin Gelso, RICoder

Forum permissions

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron