PDA

View Full Version : new operator/vertex arrays



12-24-2002, 07:46 AM
i allocate memory for my vertex arrays with the new operator and sometimes these arrays get really big.

is it possible to call new too many times becase i call it allot for dynamic memory in my program ??

my program runs fine in debug mode in visual studio. my program crashes when i run the .exe from release mode; i have traced the error down to a line that calls 'new' operator. there are alot of news before that and alot after that. (this is during program init function)

my main question is whether you can call new too many times. i assume yes but that the limit is very high; i am not allocating all that much i think and i have 512 mb of memory.

my second question is do alot of opengl implementations support storing vertex arrays in video memory or only newer ones. i would like to target a broad audience but still need to use big vertex arrays so i will need to use system memory anyway if only newer video cards allow me to put vertex arrays on the video card.

( also if i cannot fit my vertices into 512 of system memory i have no chacne of squeezing them into 64 of video memory or 32 or even 16 on older cards :P )

anyway, i know i am not burning up 512 mb with 'new'; and why does it only crash in release mode?

12-24-2002, 07:49 AM
btw i know new operator will not allocate video memory i am going to implement the extension to put them in vram later :P

B_old
12-25-2002, 02:43 PM
Why are you allocating so much memory anyway?
I did some experiments with vertex arrays the last week.
When I drew 64k (and more) billboarded quads, the fastest way was to send 128 quads to the vertex array, compute the vertices for the next 128 quads and send them and so on.
So I only allocate a vertex array for 128 quads, can draw virtually an unlimited number and it is the fastest method (at times by far!) for me.
(Of course every quad was saved somewhere, but still that doesn't mean I need a huge vertex array, the card cannot cope with it anyway I think. Sendeing all quads together was slow...)
I don't know what you are doing but I hope I could somehow help you http://www.opengl.org/discussion_boards/ubb/smile.gif.

Good luck with your program!

Jambolo
12-27-2002, 07:41 PM
If it is crashing in new, it is most likely to be caused by your code writing outside the allocated area (which may trash info that the memory allocator uses and cause it to crash later), or maybe allocating a negative or unitialized number of bytes, or freeing an allocation twice.