Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / How many 3D objects the DarkGDK support?

Author
Message
Alex Xia
14
Years of Service
User Offline
Joined: 29th Sep 2010
Location:
Posted: 29th Sep 2010 21:17
Hello guys!

When I am testing my application powered by DarkGDK. I found that
my application got runtime error if I add a large quantity of 3D objects. The debugging information shows that it is due to std::bad_alloc.

I load a .X file with size around 400K, and use it to clone objects.
If I clone 78 objects, the application works good. But if I clone 79 objects, the application crashed.

If I use a .X file with smaller size, 150K, I could create 100 objects successfully w/o any problem.

My computer has a vedio card w/ 512MB vedio memory, and 3.2G memory.

Does anyone know how to create more objects without crashing the program?

Any suggestions are highly appreciated. Sorry for poor English.
Mireben
16
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 30th Sep 2010 12:31
You should be able to create more than that. I tried to load an X model 971 K in size, with a dds texture of 2.8 MB and multiply it with dbCloneObject. I was able to create 3150 objects without problems. If I go above that number, there is still no error and even dbObjectExist returns true for all of them, but the extra objects are not rendered on the screen. (I verified that by positioning the last created object in front of the camera and rotating it.) I tried up to 5000 objects and didn't get a runtime error. Isn't there any other thing in your program that could cause the bad_alloc?

If you can reproduce the problem with a simple code, and you're sure it's a Dark GDK bug, then it's worth to report it in the "bug reports" section of the forum.
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 30th Sep 2010 20:51
looking at the gdk code, there is a limit imposed on the ID number (which implies a limit of objects) somewhere near the 1million mark. I'm not sure what error is thrrown if you exceed that number but could that be what's happening to you? Are the id's values exceeding 1million?

JTK
Alex Xia
14
Years of Service
User Offline
Joined: 29th Sep 2010
Location:
Posted: 1st Oct 2010 15:08
Mireben,
JTK,

Thanks a lot for the responses! The code for testing is like follows:

dbLoadObject("model.x", 1);
dbHideObject(1);
for ( int i = 2; i < 100; i++ )
{
dbCloneObject(i, 1);
//dbHideObject(i);
dbPositionObject(i,1,0,i);
}

I did some further check today. Now I tend to think that this might be caused by memory capacity. However, I am shocked when I
found that after the load about 80 X models using above code,
the program consumes 1.7GB memory. Why a 450K X model consumes about more than 20MB memory after it is loaded?

The X model contains animation data so I could not use dbInstanceObject(). Using dbInstanceObject() saves a lot of memory because they share the same data, but the new object could not be animated.
Morcilla
21
Years of Service
User Offline
Joined: 1st Dec 2002
Location: Spain
Posted: 2nd Oct 2010 20:07
Quote: "Why a 450K X model consumes about more than 20MB memory after it is loaded?"

Yes I've seen that before. Unfortunately I cannot remember the reason, but I think that it was related to the windows instance, as running the same program in a different machine resulted in normal memory consumption, if I remember correctly.

Login to post a reply

Server time is: 2024-11-19 18:33:19
Your offset time is: 2024-11-19 18:33:19