@@ -82,7 +82,6 @@ EmpiricalData::EmpiricalData(size_t seed, const absl::Span<const Entry> weights,
8282 : rng_(seed),
8383 alloc_ (alloc),
8484 dealloc_(dealloc),
85- usage_(0 ),
8685 total_num_allocated_(0 ),
8786 total_bytes_allocated_(0 ),
8887 birth_sampler_(BirthRateDistribution(weights)),
@@ -124,9 +123,11 @@ EmpiricalData::EmpiricalData(size_t seed, const absl::Span<const Entry> weights,
124123 absl::discrete_distribution<int > live_dist (avg_counts.begin (),
125124 avg_counts.end ());
126125
127- while (usage_ < total_mem) {
126+ size_t usage = 0 ;
127+ while (usage < total_mem) {
128128 int i = live_dist (rng_);
129129 DoBirth (i);
130+ usage += state_[i].size ;
130131 }
131132
132133 SnapshotLiveObjects ();
@@ -151,7 +152,6 @@ void* EmpiricalData::DoBirth(const size_t i) {
151152 // We have an extra live object, so the overall death rate goes up.
152153 death_sampler_.AdjustWeight (i, s.death_rate );
153154 const size_t size = s.size ;
154- usage_ += size;
155155 total_num_allocated_++;
156156 total_bytes_allocated_ += size;
157157 void * p = alloc_ (size);
@@ -167,7 +167,6 @@ void EmpiricalData::DoDeath(const size_t i) {
167167 absl::uniform_int_distribution<int >(0 , s.objs .size () - 1 )(rng_);
168168 death_sampler_.AdjustWeight (i, -s.death_rate );
169169 const size_t size = s.size ;
170- usage_ -= size;
171170 void * p = s.objs [obj];
172171 s.objs [obj] = s.objs .back ();
173172 s.objs .pop_back ();
@@ -189,7 +188,6 @@ void EmpiricalData::RecordBirth(const size_t i) {
189188void * EmpiricalData::ReplayBirth (const size_t i) {
190189 SizeState& s = state_[i];
191190 const size_t size = s.size ;
192- usage_ += size;
193191 total_num_allocated_++;
194192 total_bytes_allocated_ += size;
195193 void * p = alloc_ (size);
0 commit comments