How do you know when you run out of texture memory?

WinterMute
Site Admin
Posts: 1865
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: How do you know when you run out of texture memory?

Post by WinterMute » Thu Aug 11, 2011 12:01 am

Adding the default exception handler to your code shouldn't cause it to power off - it's more likely that you're using new to allocate memory & you just ran out.
Help keep devkitPro toolchains free, Donate today

Personal Blog

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Thu Aug 11, 2011 2:54 am

hmm the turn-off only happened when I added the exception handler.


I added the extra code and got a debug readout which looked interesting,

thanks for the 2nd BROtip

I

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Thu Aug 11, 2011 7:18 am

ok I removed some textures and shrunk some others and the game actually appeared on the DS hardware!

after a few seconds though I get a crash
it says PC:0202C0AA
addr:36E42C0D
and a lot of other letters and numbers
I might be using too much RAM, on windows it says Im using 13MB on the task manager when I run the windows version, the game doesnt make many objects really


Is there a way to see how much RAM I am using?

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Thu Aug 11, 2011 7:38 am

It crashes under the emulator at about the same time (a few seconds)

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: How do you know when you run out of texture memory?

Post by zeromus » Thu Aug 11, 2011 9:06 am

You can't tell much from how much memory your windows version uses in task manager. There may be many more things going on.
I already told you how to know how much texture memory youre using (track it yourself).
If you want to know how much ram is used then use:

Code: Select all

#include <malloc.h>
mallinfo().uordblks
You dont know how much ram you have available without using additional measures, but dont exceed ram_used + size_of_NDS_file > 3 MB file and you should be safe.
try filling your code with printfs, print every single texture or memory block you allocate, and then youll find the one thats failing. Then, all you know is, at some point then, or before, you allocated too much. A too-large allocation at any earlier point could be causing the problem.

WinterMute
Site Admin
Posts: 1865
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: How do you know when you run out of texture memory?

Post by WinterMute » Thu Aug 11, 2011 12:14 pm

slenkar wrote:ok I removed some textures and shrunk some others and the game actually appeared on the DS hardware!

after a few seconds though I get a crash
it says PC:0202C0AA
open up the msys bash shell, cd to your project directory (under msys use /c/ instead of c:\ - all slashes should be forward & tab will autocomplete). Add the devkitARM bin folder to your path with PATH=$DEVKITARM/bin:$PATH and then use arm-eabi-addr2line -e <your elf file> 0x0202C0AA

That should give you a source file and line for the crash, assuming you have -g in both CFLAGS & LDFLAGS in the Makefile.
Help keep devkitPro toolchains free, Donate today

Personal Blog

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Thu Aug 11, 2011 5:17 pm

thanks for that BROtip
apparently the line is in NEtexture.c (the nitro engine) line 377

Code: Select all

void NE_MaterialUse(NE_Material * tex)
{
if(tex == NULL)
	{
	GFX_TEX_FORMAT = 0;
	GFX_COLOR = NE_White;
	GFX_DIFFUSE_AMBIENT = ne_defaultdiffuse | (ne_defaultambient<<16) | (ne_defaultvtxcolor<<15);
	GFX_SPECULAR_EMISSION = ne_defaultspecular | (ne_defaultemission<<16) | (ne_defaultuseshininess<<15); 	
	return;
	}
	
GFX_DIFFUSE_AMBIENT = tex->diffuse | (tex->ambient<<16) | (tex->vtxcolor<<15);
GFX_SPECULAR_EMISSION = tex->specular | (tex->emission<<16) | (tex->useshininess<<15); 	

NE_Assert(tex->texindex != NE_NO_TEXTURE,"NE_MaterialUse: No texture asigned to material.");

if(NE_Texture[tex->texindex].palette)
	NE_PaletteUse(NE_Texture[tex->texindex].palette);

GFX_COLOR = (u32)tex->color;
GFX_TEX_FORMAT = NE_Texture[tex->texindex].param;
}
The line that fails is GFX_TEX_FORMAT = NE_Texture[tex->texindex].param;

its weird because the game does run for a few seconds before crashing,

Hmm, Im using a language called Monkey that converts itself into C++ and has its own garbage collection,
do you think the NE_Texture object is being garbage collected?

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: How do you know when you run out of texture memory?

Post by elhobbs » Thu Aug 11, 2011 5:51 pm

an unsupported library in an unsupported environment... you have your work cut out for you.

is nitro engine compatible with the latest devkitarm and libnds? is monkey? you may be the only person trying to do this - so I suspect that you will need to be the person to find and solve issues.

it is hard to say though, sometimes people on this forum can be quite charitable when the fancy strikes them. particulary if it looks like you are putting in some effort. if looks like you are trying to get everyone else to do the work for you then very little help will be offered

slenkar
Posts: 43
Joined: Sun Apr 17, 2011 8:10 pm

Re: How do you know when you run out of texture memory?

Post by slenkar » Thu Aug 11, 2011 6:07 pm

Using unsupported stuff is fun when it allows you to do new things. :D

Im not asking anyone to solve my problems , I realise this is all self-inflicted.

Im simply asking for the tools needed i.e. the debugging tools
which have been kindly given to me, and the opinions of forum members on whether they think its the garbage collection.
Im not asking anyone to actually DO anything at all! Im just asking questions.

Its kind of like asking a lawyer a couple of little questions vs. going into the law library and spending hours researching.(and probably not being able to get the answers)

If I do somehow get this working, it will open up development on the DS to more people, and therefore more people will donate money to wintermute.

WinterMute
Site Admin
Posts: 1865
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: How do you know when you run out of texture memory?

Post by WinterMute » Mon Aug 15, 2011 10:20 pm

Do you have a console up & running, or at least some way to display text?

Looking at the code there I'd expect it to fail on the if(NE_Texture[tex->texindex].palette) line if tex->texindex was out of bounds. That kind of suggests NE_PaletteUse is modifying something.

Basically you'll probably need to sprinkle some printf's around & check addresses of stuff.

I don't think it's garbage collection tbh but anything is possible with this :p
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests