Пример #1
0
/**
 * Try to free some memory (depending on severity).
 */
void
ecma_try_to_give_back_some_memory (mem_try_give_memory_back_severity_t severity) /**< severity of
                                                                                  *   the request */
{
    if (severity == MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_LOW)
    {
        /*
         * If there is enough newly allocated objects since last GC, probably it is worthwhile to start GC now.
         * Otherwise, probability to free sufficient space is considered to be low.
         */
        if (ecma_gc_new_objects_since_last_gc * CONFIG_ECMA_GC_NEW_OBJECTS_SHARE_TO_START_GC > ecma_gc_objects_number)
        {
            ecma_gc_run ();
        }
    }
    else if (severity == MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_MEDIUM
             || severity == MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_HIGH)
    {
        ecma_gc_run ();
    }
    else
    {
        JERRY_ASSERT (severity == MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_CRITICAL);

        /* Freeing as much memory as we currently can */
        ecma_lcache_invalidate_all ();

        ecma_gc_run ();
    }
} /* ecma_try_to_give_back_some_memory */
Пример #2
0
/**
 * Finalize ECMA components
 */
void
ecma_finalize (void)
{
  mem_unregister_a_try_give_memory_back_callback (ecma_try_to_give_back_some_memory);

  ecma_finalize_environment ();
  ecma_lcache_invalidate_all ();
  ecma_finalize_builtins ();
  ecma_gc_run ();
} /* ecma_finalize */
Пример #3
0
/**
 * Try to free some memory (depending on severity).
 */
void
ecma_try_to_give_back_some_memory (mem_try_give_memory_back_severity_t severity) /**< severity of
                                                                                  *   the request */
{
  if (severity == MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_LOW)
  {
    ecma_gc_run ();
  }
  else if (severity == MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_MEDIUM
           || severity == MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_HIGH)
  {
    /* we have already done simple GC as requests come in ascending severity order */
  }
  else
  {
    JERRY_ASSERT (severity == MEM_TRY_GIVE_MEMORY_BACK_SEVERITY_CRITICAL);

    /* Freeing as much memory as we currently can */
    ecma_lcache_invalidate_all ();

    ecma_gc_run ();
  }
} /* ecma_try_to_give_back_some_memory */