Force garbage collection/compaction with malloc().
I have a C++ program that benchmarks various algorithms on input arrays of different length. It looks more or less like this:

    # (1)
    for k in range(4..20):
      # (2)
      input = generate 2**k random points
      for variant in variants:
        benchmark the following call
        run variant on input array
      # (3)

Is it possible to reset the whole heap management at (2) to the state it had at (1)? All memory allocated on the heap that was allocated during the program is guaranteed to be freed at (3).

I am using g++ 4.3 on Linux.
Force garbage collection/compaction with malloc().
===

I have a C++ program that benchmarks various algorithms on input arrays of different length. It looks more or less like this:

    # (1)
    for k in range(4..20):
      # (2)
      input = generate 2**k random points
      for variant in variants:
        benchmark the following call
        run variant on input array
      # (3)

Is it possible to reset the whole heap management at (2) to the state it had at (1)? All memory allocated on the heap that was allocated during the program is guaranteed to be freed at (3).

I am using g++ 4.3 on Linux.