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

Memory problem with destroying surfaces


Memory problem with destroying surfaces

Postby golan_trevize_x » Jan 27, 2006 @ 1:11pm

I noticed a post similar to this, but not sure if I am having the same problem.

In the game I am making, the player can move from one level to another. When this happens:
- the many small CGapiSurfaces created for the old level are destroyed, and the heap memory freed.
- the new level is loaded, and it's surfaces are created.

I would have expected that returning to the first level again would mean no extra memory would be needed, but the game seems to be drawing more and more from the device's physical and virtual memory every time the level changes, until I simply can't move to a different level anymore.

In order to monitor the heap, I have made my own private heap pool and overloaded the new and delete operators, and all of my new and delete statements seem to be doing fine. But I can't see what Gapidraw is doing when it creates and frees the surfaces.

It seems like Gapidraw is designed for all surfaces to be loaded at the start, rather than loading and freeing throughout the game. Perhaps this is the problem for me?

Any help would be appreciated.

Nathan
golan_trevize_x
pm Member
 
Posts: 67
Joined: Nov 23, 2001 @ 7:36pm
Location: Melbourne, Australia


Postby ppcStudios » Jan 27, 2006 @ 2:22pm

One thing that I've done in the past is create generic reuseable surfaces at the start of the application. I then recreate these surfaces as my needs change (new graphics with different sizes, etc). At exit time I would then simply destroy the surfaces.

I have done it as you describe as well - create and destroy surfaces as needed - with success. In fact, this is what is done in Ancient Evil, and we've not experienced any memory allocation/deallocation issues.

You might try creating a simple application that creates and destroys surfaces and monitor it for correct functionality. Are you testing this issue in the emulator or on an actual device?
G.R. Moore
President/CEO
Pocket PC Studios
www.ppcstudios.com

Image
User avatar
ppcStudios
pm Insider
 
Posts: 744
Joined: Aug 23, 2002 @ 3:53pm
Location: Canfield, Ohio


Postby golan_trevize_x » Jan 27, 2006 @ 11:47pm

I am testing on the device (an O2 Xda II). I've never actually used the emulator.

Since I have overloaded all new and delete operators in my code, the only place where the rest of the heap memory is being sucked away is in the creation of surfaces.

I have just confirmed using a global counter that every CreateSurface call has a corresponding deletion of the surface object.
golan_trevize_x
pm Member
 
Posts: 67
Joined: Nov 23, 2001 @ 7:36pm
Location: Melbourne, Australia


Postby golan_trevize_x » Jan 28, 2006 @ 12:19am

I've been reading a few other posts - do you think the problem could be that my heap memory is getting very fragmented? When loading a new level, there is heaps of NEWing and DELETEing, not only to create the surfaces but with temporary data inbetween as well.
golan_trevize_x
pm Member
 
Posts: 67
Joined: Nov 23, 2001 @ 7:36pm
Location: Melbourne, Australia


Postby golan_trevize_x » Jan 29, 2006 @ 3:20am

golan_trevize_x
pm Member
 
Posts: 67
Joined: Nov 23, 2001 @ 7:36pm
Location: Melbourne, Australia


Return to GapiDraw


Sort


Forum Description

The Cross-platform Graphics SDK for Palms, Pocket PCs, Symbian Devices, and Stationary PCs.

Moderators:

sponge, Johan

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