Repository: paritytech/substrate
File: client/allocator/src/freeing_bump.rs (Rust)

Code before:
				let next_free = Header::read_from(mem, header_ptr)?
					.into_free()
					.ok_or_else(|| error("free list points to a occupied header"))?;
				self.free_lists[order] = next_free;

				header_ptr
			},
			Link::Nil => {
				// Corresponding free list is empty. Allocate a new item.
				Self::bump(&mut self.bumper, order.size() + HEADER_SIZE, mem.size())?
			},
		};

		// Write the order in the occupied header.
		Header::Occupied(order).write_into(mem, header_ptr)?;
		self.total_size += order.size() + HEADER_SIZE;

		if order.size() + HEADER_SIZE > 8 * 1024 * 1024 {
			log::warn!(
				target: LOG_TARGET,
				"large allocation of {} detected, after allocation, total_size = {}, bumper = {}.",
				order.size() + HEADER_SIZE,
				self.total_size,
				self.bumper,
			);
		}

		log::trace!(
			target: LOG_TARGET,
			"after allocation, total_size = {}, bumper = {}.",
			self.total_size,
			self.bumper,
		);

		// update trackers if needed.
		if self.total_size > self.max_total_size {
			self.max_total_size = self.total_size;
		}
		if self.bumper > self.max_bumper {
			self.max_bumper = self.bumper;
		}

		bomb.disarm();
		Ok(Pointer::new(header_ptr + HEADER_SIZE))
	}

	/// Deallocates the space which was allocated for a pointer.
	///
	/// The identity or the type of the passed memory object does not matter. However, the size of
	/// memory cannot shrink compared to the memory passed in previous invocations.
	///

Review comment (suggestion):
Yeah, I think this will definitely be spammy so it shouldn't stay as a `warn`.

This reminds me though, it'd probably be useful to add some sort of logging capability so that a log of every allocation from within the runtime could be dumped into a file; something like my [Bytehound](https://github.com/koute/bytehound), but for the runtime instead of the native code. (Obviously totally out of scope of this PR though.)

Code after:
					.into_free()
					.ok_or_else(|| error("free list points to a occupied header"))?;
				self.free_lists[order] = next_free;

				header_ptr
			},
			Link::Nil => {
				// Corresponding free list is empty. Allocate a new item.
				Self::bump(&mut self.bumper, order.size() + HEADER_SIZE, mem.size())?
			},
		};

		// Write the order in the occupied header.
		Header::Occupied(order).write_into(mem, header_ptr)?;

		self.total_size += order.size() + HEADER_SIZE;

		log::trace!(
			target: LOG_TARGET,
			"after allocation, total_size = {}, bumper = {}.",
			self.total_size,
			self.bumper,
		);

		// update trackers if needed.
		if self.total_size > self.max_total_size {
			self.max_total_size = self.total_size;
		}
		if self.bumper > self.max_bumper {
			self.max_bumper = self.bumper;
		}

		bomb.disarm();
		Ok(Pointer::new(header_ptr + HEADER_SIZE))
	}

	/// Deallocates the space which was allocated for a pointer.
	///
	/// The identity or the type of the passed memory object does not matter. However, the size of
	/// memory cannot shrink compared to the memory passed in previous invocations.
	///
	/// NOTE: Once the allocator has returned an error all subsequent requests will return an error.
	///
	/// # Arguments
	///
	/// - `mem` - a slice representing the linear memory on which this allocator operates.
	/// - `ptr` - pointer to the allocated chunk
	pub fn deallocate<M: Memory + ?Sized>(
		&mut self,
		mem: &mut M,
		ptr: Pointer<u8>,