Re:In what cases is Java faster than C++?
by ekidd on Wednesday February 16, 2011 @10:25AM
(#2226684)
Really? One allocation every 50 to 100ms? That would mean you could only do 10 to 20 memory allocations per second. Now, I know that malloc is often very slow, but that seems unlikely.
Or do you mean 50 to 100 microseconds? That's still horrible, but I could believe it.
Re:In what cases is Java faster than C++?
by mrcharles on Wednesday February 16, 2011 @10:39AM
(#2226749)
Oops, yeah, I meant microseconds. Will fix it.
Re:In what cases is Java faster than C++?
by ekidd on Wednesday February 16, 2011 @10:42AM
(#2226773)
Thank you. Malloc can be pretty bad, but we don't want to start any crazy rumors about it. :-)
Re:In what cases is Java faster than C++?
by npalli on Wednesday February 16, 2011 @10:35AM
(#2226726)
50-100ms is just horrible. In fact, the best malloc's show operations in 50-100 nanoseconds.
Re:In what cases is Java faster than C++?
by jedbrown on Wednesday February 16, 2011 @10:44AM
(#2226784)
Yes, even glibc malloc is usually around 400 cycles (about 150 nanoseconds) in my tests.
Re:In what cases is Java faster than C++?
by JoeAltmaier on Wednesday February 16, 2011 @11:05AM
(#2226910)
Windows "garbage collects" in its memory manager anyway; so no actually benefit using C++ etc there. It uses some pool with fragmentation algorithms that can take 100s of milliseconds to complete.
But at that time, I wrote a memory manager which had malloc and free calls which were a magnitude faster, at least ten times.
When you need it to be fast, it can be fast. If you don't want it to be fast, or you have to resort to tricks like preventing the compiler from inlining (wtf?), then you really are doing it wrong.