gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

C/C++ > Out Of Memory...

#23818 - Krakken - Thu Jul 22, 2004 6:28 am

Hi,

I have a very strange problem that I need some help with. I'm currently working on a project in which I am using my class library to control it all. I have several different classes to control the different aspects of the GBA workings and all are not amazingly huge. In my code I have declared aboout 15 of those classes as objects I can use.

The problem I am having is my code executes flawlessly on all emulators but on the actual hardware some of my sprites were missing. I was trying to figure out the problem for hours before I finally realised that maybe it wasn't something in my code but rather a memory problem. You see, the sprites that wern't showing were the last class objects that are declared in my code. I swapped the order in which they are created and now the sprites that wern't showing before were showing and vice versa.

I checked the ExWRAM and IWRAM in the emulator and for some odd reason they were empty. Shouldn't the classes and my objects be stored here?

The very strange thing is that there is 256kb of ExWRAM and I can't see why it would be using an amount even close to this, so why am I getting this problem?

Thanks, Nat.

#23819 - sajiimori - Thu Jul 22, 2004 6:52 am

There's no way to tell from here. It could be a bug completely unrelated to memory usage. Memory usage will be the same on VBA and hardware. Print lots of debug info to track your program.

IWRAM and EWRAM will be empty initially, but if you're using DevKitAdvance or similar then IWRAM will be used for a stack and for static/global variables, and EWRAM will be used for malloc/new.

#23821 - tepples - Thu Jul 22, 2004 9:35 am

Are you using the priority bits of the OAM entries? If so, go to the FAQ, read "Q: How do I draw things behind things?", and see if it helps any.

By default, the compiler puts nothing in EWRAM when building a ROM. You have to explicitly tell the compiler that you want something put in EWRAM.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#23826 - Krakken - Thu Jul 22, 2004 12:48 pm

Nope not using priority bits. I assumed that if left unchanged that all sprites are drawn over the background?

#23846 - Miked0801 - Fri Jul 23, 2004 12:21 am

Too many sprites on a line perhaps? Are the sprites that aren't appearing showing up as missing square? If so, that may be your problem.

#23866 - Krakken - Fri Jul 23, 2004 6:22 am

I'm only using two sprites.
It's so strange. Why would it work on _all_ emulators and not the hardware?

#23874 - sgeos - Fri Jul 23, 2004 9:48 am

Hardware is fussy.

-Brendan

#23879 - Krakken - Fri Jul 23, 2004 12:54 pm

Seems so. Can anyone recommend anything I should try?

#23880 - poslundc - Fri Jul 23, 2004 1:37 pm

Reduce the complexity of the problem. Pare your code down so you are just displaying simple sprites without all of the extra classes. Get it so that it works, then begin layering the complexity back on and find out at what point the hardware becomes inconsistent with the emulator.

Tracking down the source of a problem is oftentimes 90% of the work that goes into debugging.

Dan.