Hey, I''ve got this model format of mine. One thing it does looks like this.
GLfloat (*mesh)[3];
mesh = new GLfloat[polycount*3][3];
This part crashes every time a load a large model. The smallest one that has crashed this line is a 2881 polycount model. That would be allocating it like this.
mesh = new GLfloat[8643][3];
Is there some known reason as to why this would happen? Small models work just fine. I do not know exactly at what polycount it starts to crash, but I do know it''s big models that do it. Thanks for any help.
Alex Broadwin
A-Tronic Software & Design
-----
"if you fail in life, you were destined to fail. If you suceed in life, call me."
"The answer is out there."
"Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
Does it crash on allocation ? Does it actually allocate the memory ? Does it crash on access ? What error does it crash with ? Have you tried using a std::vector<> ? (passing &v[0] is backwards-compatible with C array arguments) Have you tried using a struct instead of an array for the coordinates of an individual vertex ? Can you see the fnords ?
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
the problem may be that there is not enough contiguous memory for an array that size, so the allocation fails (do you check it?), and then the crash occurs later when you try to use that memory (which isn''t really there for you to use)
I''m not sure that the syntaxis of the allocation is right. You can try to change the allocation as follows : GLfloat (*mesh)[3]; mesh = new GLfloat[polycount*3*3];
if that doesn''t work try with this one :
GLfloat (*mesh)[3]; mesh[0] = new GLfloat[polycount*3]; mesh[1] = new GLfloat[polycount*3]; mesh[2] = new GLfloat[polycount*3];
-It crashes on the first allocation -It is correct syntax, works with smaller models -It crashes within the block move when allocating vertex data -I am posative of all of that
Alex Broadwin A-Tronic Software & Design ----- "if you fail in life, you were destined to fail. If you suceed in life, call me." "The answer is out there." "Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
Alex Broadwin A-Tronic Software & Design ----- "if you fail in life, you were destined to fail. If you suceed in life, call me." "The answer is out there." "Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
If malloc succeeds then it is a layout problem rather than an allocation problem.
quote:Original post by ATronic -It crashes within the block move when allocating vertex data
Can you post the code copying the block ?
Edited by - Fruny on November 30, 2001 9:45:10 AM
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
Actually, if you look at the post I put the address to, you will see some other information. What happens is this. I allocate the memory using new. New ultimately calls malloc, which does it''s thing with the var pools and such. Then it goes to link_new_block. Then, in kernel32.dll the following is done.
Alex Broadwin A-Tronic Software & Design ----- "if you fail in life, you were destined to fail. If you suceed in life, call me." "The answer is out there." "Please help, I''m using Windows!"
Alex BroadwinA-Tronic Software & Design-----"if you fail in life, you were destined to fail. If you suceed in life, call me.""The answer is out there.""Please help, I'm using Windows!"
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan