I want to render 4 millions triangles in my windows based software which is written in Visual Studio C++ 2010 (Build in Release Mode). When I render 3.9 millions triangles,
For one of the questions:
is there any diffirence between these two?
the different between new and malloc is as follows:
malloc is used in C, malloc allocates uninitialized memory. The allocated memory has to be released with free.
new initializes the allocated memory by calling the corresponding constructor. Memory allocated with new should be released with delete (which calls the destructor). You don't need to give the size of memory block in order to release the allocated memory.
It is not clear whether new and malloc are related according to the standard (it depends on whether a specific compiler implements new using malloc or not), so the issue may or may not be resolved by simply replacing new with malloc.
From the code you showed, it is difficult to spot the cause of error. You may try to replace the dynamic array with vector to see if it solves your problem. Meanwhile, you may use valgrind to check whether you have memory leak in your code (if you can somehow port your code to Linux with makefiles since unfortunately valgrind is not available on Windows.).