5 ms·
There's no way that real memory allocation is faster in C# than in C++. I don't know much about the CLR, but if it appears to allocate memory faster, it is pro
by humbledrone 17y ago
There's no way that real memory allocation is faster in C# than in C++. I don't know much about the CLR, but if it appears to allocate memory faster, it is probably because it is taking the memory from a pool which it has already allocated from the OS. You can do that in C++ if you want, using e.g. boost::pool.
- stonemetal 17y agoAs with most compacting collecting languages memory allocation is a space check and a pointer increment. In C++ new has to do quite a bit more. It is about Java but C# is capable of the same. http://www.ibm.com/developerworks/java/library/j-jtp09275.html http://www.ibm.com/developerworks/java/library/j-jtp09275.ht... Also note that C++'s memory model is "single threaded" new must grab a global lock where as C#'s memory allocator is designed with threads in mind so no locking overhead.