middle.c 504 B

12345678910111213141516171819202122232425
  1. /*
  2. * Test at the boundary between small and large objects.
  3. * Inspired by a test case from Zoltan Varga.
  4. */
  5. #include "gc.h"
  6. #include <stdio.h>
  7. int main (void)
  8. {
  9. int i;
  10. GC_set_all_interior_pointers(0);
  11. GC_INIT();
  12. for (i = 0; i < 20000; ++i) {
  13. (void)GC_malloc_atomic(4096);
  14. (void)GC_malloc(4096);
  15. }
  16. for (i = 0; i < 20000; ++i) {
  17. (void)GC_malloc_atomic(2048);
  18. (void)GC_malloc(2048);
  19. }
  20. printf("Final heap size is %lu\n", (unsigned long)GC_get_heap_size());
  21. return 0;
  22. }