On Apr 10, 9:58 pm, Razii
> On Thu, 10 Apr 2008 21:43:45 -0400, Arne Vajh=F8j
> wrote:
>
> >I can not imagine any C++ runtime that makes an operating system
> >call for each new.
>
> >The runtime allocates huge chunks from the OS and then manage
> >it internally.
>
> Testing the keyword "new"
>
> Time: 2125 ms (C++)
> Time: 328 ms (java)
>
> Explain that. What I am doing different in java than in c++? Code
> below..
What you are doing differently is not freeing the memory. Since you
are allocating gobs of memory, and not releasing it, the C++ version
will incur the cost of page faults, virtual memory access, disk
thrashing, etc. You are timing a lot more than just memory
allocation. Of course a lot of people use contrived examples like
this to prove their pet language is faster than another. What a waste
of time...
REH