@@ -209,7 +209,6 @@ typedef struct rb_objspace {
209209 struct {
210210 size_t limit ;
211211 size_t increase ;
212- size_t increase2 ;
213212#if CALC_EXACT_MALLOC_SIZE
214213 size_t allocated_size ;
215214 size_t allocations ;
@@ -272,7 +271,6 @@ int *ruby_initial_gc_stress_ptr = &rb_objspace.gc_stress;
272271#endif
273272#define malloc_limit objspace->malloc_params.limit
274273#define malloc_increase objspace->malloc_params.increase
275- #define malloc_increase2 objspace->malloc_params.increase2
276274#define heaps objspace->heap.ptr
277275#define heaps_length objspace->heap.length
278276#define heaps_used objspace->heap.used
@@ -1978,8 +1976,6 @@ before_gc_sweep(rb_objspace_t *objspace)
19781976 objspace -> heap .free_num = 0 ;
19791977 objspace -> heap .free_slots = NULL ;
19801978
1981- malloc_increase2 += ATOMIC_SIZE_EXCHANGE (malloc_increase ,0 );
1982-
19831979 /* sweep unlinked method entries */
19841980 if (GET_VM ()-> unlinked_method_entry_list ) {
19851981 rb_sweep_method_entry (GET_VM ());
@@ -1998,9 +1994,6 @@ after_gc_sweep(rb_objspace_t *objspace)
19981994 }
19991995
20001996 inc = ATOMIC_SIZE_EXCHANGE (malloc_increase , 0 );
2001- inc += malloc_increase2 ;
2002- malloc_increase2 = 0 ;
2003-
20041997 if (inc > malloc_limit ) {
20051998 malloc_limit +=
20061999 (size_t )((inc - malloc_limit ) * (double )objspace -> heap .marked_num / (heaps_used * HEAP_OBJ_LIMIT ));
@@ -3486,9 +3479,8 @@ vm_malloc_prepare(rb_objspace_t *objspace, size_t size)
34863479 size += sizeof (size_t );
34873480#endif
34883481
3489- ATOMIC_SIZE_ADD (malloc_increase , size );
34903482 if ((ruby_gc_stress && !ruby_disable_gc_stress ) ||
3491- malloc_increase > malloc_limit ) {
3483+ ( malloc_increase + size ) > malloc_limit ) {
34923484 garbage_collect_with_gvl (objspace );
34933485 }
34943486
@@ -3498,6 +3490,8 @@ vm_malloc_prepare(rb_objspace_t *objspace, size_t size)
34983490static inline void *
34993491vm_malloc_fixup (rb_objspace_t * objspace , void * mem , size_t size )
35003492{
3493+ ATOMIC_SIZE_ADD (malloc_increase , size );
3494+
35013495#if CALC_EXACT_MALLOC_SIZE
35023496 ATOMIC_SIZE_ADD (objspace -> malloc_params .allocated_size , size );
35033497 ATOMIC_SIZE_INC (objspace -> malloc_params .allocations );
@@ -4083,7 +4077,7 @@ gc_prof_set_malloc_info(rb_objspace_t *objspace)
40834077 if (objspace -> profile .run ) {
40844078 gc_profile_record * record = & objspace -> profile .record [objspace -> profile .count ];
40854079 if (record ) {
4086- record -> allocate_increase = malloc_increase + malloc_increase2 ;
4080+ record -> allocate_increase = malloc_increase ;
40874081 record -> allocate_limit = malloc_limit ;
40884082 }
40894083 }
0 commit comments