We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6b51c61 commit fe49c5bCopy full SHA for fe49c5b
core/shared/mem-alloc/ems/ems_gc_internal.h
@@ -338,8 +338,18 @@ typedef struct gc_heap_struct {
338
static inline void
339
gc_update_threshold(gc_heap_t *heap)
340
{
341
- heap->gc_threshold =
342
- heap->total_free_size * heap->gc_threshold_factor / 1000;
+ uint64_t result = (uint64_t)heap->total_free_size
+ * (uint64_t)heap->gc_threshold_factor / 1000;
343
+ if (result > UINT32_MAX) {
344
+ /* Threshold factor can be greater than 1000 (100%), which means
345
+ * GC will never be triggered. So heap->gc_threshold >
346
+ * APP_HEAP_SIZE_MAX is allowed
347
+ */
348
+ heap->gc_threshold = UINT32_MAX;
349
+ }
350
+ else {
351
+ heap->gc_threshold = (uint32_t)result;
352
353
}
354
355
#define gct_vm_mutex_init os_mutex_init
0 commit comments