My game crashes on quit...

Member
Posts: 153
Joined: 2004.12
Post: #16
PowerMacX Wrote:Each wavefront should probably be responsible for releasing all the memory/objects it allocated, and should do so in it's destructor (structs can have destructors too, class & struct are basically the same for C++, the only difference being that class defaults to private member variables and struct to public)

Anyway, if you don't release your objects before the application exits the system should take care of it, so for now you should comment all the "memory release" portions of your code. Start commenting stuff out until it doesn't crash to find exactly what causes it.

Does the crash occur if you run it in the debbuger?

Perhaps it's just some glut callback you forgot to set?

1.) I don't have any "memory release" code. So far everything i use i need till termination...

2.) it does not crash the debugger

3.) if it had anything to do with glut the crash wouldn't be dependent on how many 'slots' i allocate the array with. Remember if I only allocate the array with one slot it doesn't crash.

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Member
Posts: 153
Joined: 2004.12
Post: #17
wadesworld Wrote:Do your objects contain CoreFoundation collections such as CFString, CFArray, etc? That's where the crash is coming from.

Although it's always good practice to delete something you allocated, with an allocation using new or malloc, it won't cause a program crash if the object is not deleted. Maybe you're sending a CFRelease to the elements of a CFArray?

Wade

Nope

typedef struct
{
float x,y,z;

}vertex;

typedef struct
{
int vIndex[4];
int tIndex[4];
int gId;
}face;

typedef struct
{
char texName[16];
int gId;

}group;

typedef struct
{
tgaTexture *textures;
}texture;

typedef struct
{
group *groups;
int nVertices, nTVertices, nFaces;
vertex *vertices;
vertex *tVertices;
face *faces;
texture *textureWrapper;

}wavefront;

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Member
Posts: 153
Joined: 2004.12
Post: #18
Well i cant even begin to explain what the problem was but i somehow managed to fix it.

Every frame i loop through my array of OBJ's and display them to the user. I first check if the object has a textureID... if(object.textureWrapper[object.faces[count].gId].textures[0].textID)
if it does i use texturing if it doesn't i don't.

I noticed my app crashed if i didnt give my objects textures (different crash then the one this thread is about). This was because i dont allocate textureWrapper unless i give an obj a texture. So checking for textID IN textureWrapper when it was never allocating it was crashing my program. I changed the if to simply check for textureWrapper in an attempt to fix the second bug and for some unexplainable reason it fixed both bugs.

WHY the glutMainLoop was executing AFTER my log says its stoped i don't know. BUT it fixed my problem and im happy.

Thanks you all for your help. I really appreciate your time. Hopefully some day soon il have something to show the community.

Smile

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Why free memory on application quit? Najdorf 32 13,964 Jan 5, 2009 12:19 AM
Last Post: Lycander
  I'm going CRAZY!!! Random crashes without reason akb825 3 3,618 Aug 18, 2005 03:46 PM
Last Post: akb825
  pathfinding crashes Iceman 5 4,331 Jul 28, 2005 05:48 PM
Last Post: unknown
  My application crashes MACnus 2 2,526 Dec 31, 2004 01:35 AM
Last Post: MACnus
  Carbon Apple quit Event troubles deekpyro 3 5,988 May 7, 2002 06:24 AM
Last Post: deekpyro