nobody, you can see how the GC interacts with your code also with the following
small D1 program:
import std.c.stdlib: malloc;
struct S { int i; }
void main() {
const N = 20_000_000;
static if (true) // change this to false
S** sa = cast(S**)calloc(N, (S*).sizeof);
else
$ g++ alloc.cpp -o alloc
$ time ./alloc
real0m1.946s
user0m1.688s
sys 0m0.256s
$ dmd -O -release allocd.d
$ time ./allocd
real0m22.734s
user0m22.353s
sys 0m0.360s
$ cat alloc.cpp
#include vector
typedef std::vectorint intvec;
typedef intvec* intvecp;
int main() {
nobody, el 22 de mayo a las 00:08 me escribiste:
$ g++ alloc.cpp -o alloc
$ time ./alloc
real0m1.946s
user0m1.688s
sys 0m0.256s
$ dmd -O -release allocd.d
$ time ./allocd
real0m22.734s
user0m22.353s
sys 0m0.360s
$ cat alloc.cpp
#include vector
== Quote from nobody (n...@where.com)'s article
$ g++ alloc.cpp -o alloc
$ time ./alloc
real0m1.946s
user0m1.688s
sys 0m0.256s
$ dmd -O -release allocd.d
$ time ./allocd
real0m22.734s
user0m22.353s
sys 0m0.360s
$ cat alloc.cpp
#include vector
typedef
You've probably hit a corner case for the garbage collector. When you
allocate
20,000,000 Object instances and hold onto the references, the garbage
collector
probably runs about a zillion times and never finds anything to delete. If
this
is a bottleneck, you should temporarily disable
nobody wrote:
$ g++ alloc.cpp -o alloc
$ time ./alloc
real0m1.946s
user0m1.688s
sys 0m0.256s
$ dmd -O -release allocd.d
$ time ./allocd
real0m22.734s
user0m22.353s
sys 0m0.360s
$ cat alloc.cpp
#include vector
typedef std::vectorint intvec;
typedef intvec*
Robert Fraser wrote:
nobody wrote:
$ g++ alloc.cpp -o alloc
$ time ./alloc
real0m1.946s
user0m1.688s
sys 0m0.256s
$ dmd -O -release allocd.d
$ time ./allocd
real0m22.734s
user0m22.353s
sys 0m0.360s
$ cat alloc.cpp
#include vector
typedef std::vectorint intvec;
nobody wrote:
You've probably hit a corner case for the garbage collector. When you allocate
20,000,000 Object instances and hold onto the references, the garbage collector
probably runs about a zillion times and never finds anything to delete. If this
is a bottleneck, you should temporarily