Пример #1
0
int
main ()
{
  TEST_INIT ();

  jmem_init ();

  for (uint32_t i = 0; i < test_iters; i++)
  {
    const size_t subiters = ((size_t) rand () % TEST_MAX_SUB_ITERS) + 1;

    for (size_t j = 0; j < subiters; j++)
    {
      ptrs[j] = (uint8_t *) jmem_pools_alloc ();

      if (ptrs[j] != NULL)
      {
        for (size_t k = 0; k < JMEM_POOL_CHUNK_SIZE; k++)
        {
          ptrs[j][k] = (uint8_t) (rand () % 256);
        }

        memcpy (data[j], ptrs[j], JMEM_POOL_CHUNK_SIZE);
      }
    }

    /* jmem_heap_print (false); */

    for (size_t j = 0; j < subiters; j++)
    {
      if (rand () % 256 == 0)
      {
        jmem_pools_collect_empty ();
      }

      if (ptrs[j] != NULL)
      {
        JERRY_ASSERT (!memcmp (data[j], ptrs[j], JMEM_POOL_CHUNK_SIZE));

        jmem_pools_free (ptrs[j]);
      }
    }
  }

#ifdef JMEM_STATS
  jmem_pools_stats_print ();
#endif /* JMEM_STATS */

  jmem_finalize (false);

  return 0;
} /* main */
Пример #2
0
/**
 * Print memory usage statistics
 */
void
jmem_stats_print (void)
{
  jmem_heap_stats_print ();
  jmem_pools_stats_print ();
} /* jmem_stats_print */