N8: Stop the soak player holding old islands, and count live islands
The soak's client memory growth (17 to 20 MB, about five islands, in some processes) came from SoakPlayer keeping a strong reference to the last world it played on. It let go only when its client next asked it for a command on the new world, so finished islands stayed alive across a match change. It now keeps only the island's seed. LiveCount counts live Simulations and SimGrounds, which are made on worker threads too, so it is thread-safe. The soak clients log the counts, and the soak report fails if, a minute into a match, any island is alive that isn't a client's world or one being made. That makes a leak name itself instead of showing up as bytes. Refs #39 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
extends TestCase
|
||||
|
||||
## N8 (#39): the soak's scripted client must not keep a finished match's island alive,
|
||||
## and the live counts the soak's leak check reads must follow islands as they come and go.
|
||||
|
||||
|
||||
func test_soak_player_lets_go_of_the_last_island() -> void:
|
||||
var before: int = LiveCount.of(&"Simulation")
|
||||
var player: SoakPlayer = SoakPlayer.new(3)
|
||||
var world: Simulation = Simulation.new(4, SimGround.flat(2.0))
|
||||
assert_eq(LiveCount.of(&"Simulation"), before + 1)
|
||||
var me: SimEntity = world.entities.find(world.add_player())
|
||||
assert_not_null(player.command(10, me, world))
|
||||
me = null
|
||||
world = null
|
||||
assert_eq(LiveCount.of(&"Simulation"), before, "the player held on to the island")
|
||||
|
||||
|
||||
func test_soak_player_finds_the_top_again_on_a_new_island() -> void:
|
||||
var player: SoakPlayer = SoakPlayer.new(0)
|
||||
var low: Simulation = Simulation.new(4, SimGround.flat(2.0))
|
||||
player.command(1, low.entities.find(low.add_player()), low)
|
||||
var first: Vector2 = player.get("_top")
|
||||
var other: Simulation = Simulation.new(5)
|
||||
player.command(2, other.entities.find(other.add_player()), other)
|
||||
assert_ne(player.get("_top"), first, "a new seed, a new high point")
|
||||
|
||||
|
||||
func test_grounds_are_counted_while_alive() -> void:
|
||||
var before: int = LiveCount.of(&"SimGround")
|
||||
var held: Array[SimGround] = [SimGround.flat(1.0)]
|
||||
assert_eq(LiveCount.of(&"SimGround"), before + 1)
|
||||
held.clear()
|
||||
assert_eq(LiveCount.of(&"SimGround"), before)
|
||||
Reference in New Issue
Block a user