C
Chris M. Thomasson
Juha Nieminen said:I assume you are not using gcc? Or you are using your own specialized
allocator?
Ummm, what about something simple like:
C++ version:
___________________________________________________________
#include <cstdlib>
struct foo
{
int m_foo;
};
int
main()
{
for (int i = 0; i < 1000; ++i)
{
std::free(std::malloc(10000000 * sizeof(foo)));
}
return 0;
}
___________________________________________________________
Java version:
___________________________________________________________
public final class tree
{
int m_foo;
public static void main(String[] args) {
for (int i = 0; i < 1000; ++i)
{
tree[] t = new tree[10000000];
}
}
}
___________________________________________________________
Here is the output I get for the C++ version:
___________________________________________________________
$ time ./test
real 0m0.159s
user 0m0.046s
sys 0m0.031s
___________________________________________________________
Here is the output I get for the Java version:
___________________________________________________________
$ time java tree
real 1m36.386s
user 0m0.046s
sys 0m0.031s
___________________________________________________________
Am I doing something wrong in the Java version? Keep in mind that the old
platform I am using right now only has 512mb of ram. C++ seems to do fine,
Java... Not so much. I must be missing something important here!
;^/