Memory increasing for seemingly no reason at all?

(I’m using version 4.2.1.stable.)

My game seems to have a memory leak of sorts, however I really don’t have a clue what’s causing it. The cause seems to change at random - sometimes it’ll happen, sometimes it won’t. Sometimes tabbing in and out causes it, other times it’ll skyrocket from 200mb of ram used to over 13gb. That’s really not good.

This is especially bad when the game is maximised, no idea why.

The only things being loaded in are sound effects. Everything else is loaded when the game starts.

In this video the memory went up after being hit (sometimes?) or when the player hits the ball and is stalling with it. I genuinely have no idea why. My code isn’t the best but everything online I’ve seen about memory leaks (if that’s the right thing to call what’s happening here) says it’s to do with loading in objects or nodes but that just isn’t a thing in this game, at least not yet.

If you need any more specific info I’ll be happy to provide it but my code isn’t really the best so sorry if it causes any heart attacks. Thanks in advance

Can you show code where you load things in and say what you do with those things?

1 Like

In Project settings activate "Advanced settings" checkbox and check Verbose stdout (Full path will Debug-Settings-Verbose stdout, Debug section not visible by default)
Also good thing to run whole Godot with flag --verbose
In Output may be useful info

1 Like

It’s pretty much just loading a random sound on hit, which doesn’t really seem to be causing the problem I think? Stuff like this:

$fs.stream = load("res://sound/fs" + str(rand) + ".mp3")

Sounds are the only things being loaded with load(). I’m in the process of preloading every required asset and using them that way, but no nodes or scenes are loaded or instanced - what you see in the video is the root scene (for now). Not sure if this helps

What exactly does this do? I’ve enabled it but it doesn’t really seem to have changed all that much. I’ve been checking the monitors on top of all this but I really can’t figure out what’s causing it. Every culprit I’ve suspected I’ve disabled entirely and tried playing the game and the exact same thing will happen.

Do you instantiate scenes anywhere?

Nope, not through code at least. Unsure if instancing scenes through the engine can cause this issue but surely it wouldn’t raise memory usage through the roof at seemingly random?
image

After enabling this setting look into Output tab (left down corner ar your screenshot). It shows loaded scenes, files, resources and can show memory leak.

This is all that shows up. Is there no way to see what exactly is in memory right now, or what process/script/whatever is using however much ram?

Running: C:/Users/jenny/Downloads/Godot_v4.2.1-stable_win64.exe/Godot_v4.2.1-stable_win64.exe
 --verbose
 --path
 C:/Users/jenny/Desktop/GP2Rewrite/Gremlinball-Repo/GREMLINBALL
 --remote-debug
 tcp://127.0.0.1:6007
 --editor-pid
 45084
 --debug-collisions
 --position
 1344,708
 res://scenes/game.tscn
Godot Engine v4.2.1.stable.official.b09f793f5 - https://godotengine.org
TextServer: Added interface "Dummy"
TextServer: Added interface "ICU / HarfBuzz / Graphite (Built-in)"
Vulkan devices:
  #0: NVIDIA NVIDIA GeForce RTX 3090 - Supported, Discrete
Vulkan API 1.3.260 - Forward+ - Using Vulkan Device #0: NVIDIA - NVIDIA GeForce RTX 3090
Optional extension VK_KHR_incremental_present not found
Optional extension VK_GOOGLE_display_timing not found
- Vulkan Variable Rate Shading supported:
  Pipeline fragment shading rate
  Primitive fragment shading rate
  Attachment fragment shading rate, min texel size: (16, 16), max texel size: (16, 16)
- Vulkan multiview supported:
  max view count: 32
  max instances: 134217727
- Vulkan subgroup:
  size: 32
  min size: 32
  max size: 32
  stages: STAGE_VERTEX, STAGE_TESSELLATION_CONTROL, STAGE_TESSELLATION_EVALUATION, STAGE_GEOMETRY, STAGE_FRAGMENT, STAGE_COMPUTE, STAGE_RAYGEN_KHR, STAGE_ANY_HIT_KHR, STAGE_CLOSEST_HIT_KHR, STAGE_MISS_KHR, STAGE_INTERSECTION_KHR, STAGE_CALLABLE_KHR, STAGE_TASK_NV, STAGE_MESH_NV
  supported ops: FEATURE_BASIC, FEATURE_VOTE, FEATURE_ARITHMETIC, FEATURE_BALLOT, FEATURE_SHUFFLE, FEATURE_SHUFFLE_RELATIVE, FEATURE_CLUSTERED, FEATURE_QUAD, FEATURE_PARTITIONED_NV
  quad operations in all stages
Startup PSO cache (4.8 MiB)
Using "wintab" pen tablet driver...
Creating VMA small objects pool for memory type index 1
Shader 'CanvasSdfShaderRD' (group 0) SHA256: ccda596da71a96af6897be3bc63633145694ec79105c5674ee719a025f168249
Shader 'SkeletonShaderRD' (group 0) SHA256: db547e2a7abfceddca6daece649af33b18189dc08eaa37cef9dc5860862b91ee
Shader 'SortShaderRD' (group 0) SHA256: 0635218ab1b23b93c0e100ad9a6fe7be993089593c96fb6f498e0f9d047ce9f4
Shader 'ParticlesShaderRD' (group 0) SHA256: bfea0e55dd78696fd416c3513873f5a94bc956c2a61b8292eb5d078690e41591
Shader 'ParticlesCopyShaderRD' (group 0) SHA256: b640b70d21ec3903c8e257f1d54ef3c64236018b36feffb7a955f8cbf2b977c4
Shader 'CanvasShaderRD' (group 0) SHA256: f2af9ca0e26c0e8049ed431865d8fd5d14faf79f1ba8dade11df8dbd611652c3
Shader 'CanvasOcclusionShaderRD' (group 0) SHA256: 6e1f14f7d04af941e1d2300431ef37d7e2742684dce4fbe7495def98a3b1cb4d
Shader 'ClusterRenderShaderRD' (group 0) SHA256: 2135e66bae082ab8c6b6d9b8513777bd4aae70f47ed40a170cc241c0696d57dd
Shader 'ClusterStoreShaderRD' (group 0) SHA256: e7c19c07bf7cf7209e469a9fbb06d30b27bf29d7ad91bc47e74e0631765b2d86
Shader 'ClusterDebugShaderRD' (group 0) SHA256: 96afdc9dc3999abd6dc9e98643b3d58644ec856e4fa4ea20f9f69e1b225d6af8
Shader 'SceneForwardClusteredShaderRD' (group 0) SHA256: d5ded1b6d087f9d205de57ed54272037445fd80bbbab48e31e53a3fe33da0710
Shader 'SceneForwardClusteredShaderRD' (group 1) SHA256: 48092b10c0c4dd4c2e716f8fc6f699428872bad85dd07c65b7903c8732acba2a
Shader 'SceneForwardClusteredShaderRD' (group 2) SHA256: 5878195f2ab9a62223312633ac117c7b61974128c353968d1e66c80efb298e03
Shader 'SceneForwardClusteredShaderRD' (group 3) SHA256: 13816f69baf68044a6820cb07e9d2c069d84975407c2560320b8a551545e42cb
Shader 'ResolveShaderRD' (group 0) SHA256: bbae2281243fdb9a2fc1e014df1debab098cfa3fcafe9ee75283d37df2d1fddf
Shader 'TaaResolveShaderRD' (group 0) SHA256: 75850220cf4a882155831df3c46894bb18d5c770308ec844ff00d09520802a9b
Shader 'Fsr2DepthClipPassShaderRD' (group 0) SHA256: 2830090de5d5209b66e51f2bab8566480a2115c0f1b50534f9a18ac00b9be4bd
Shader 'Fsr2ReconstructPreviousDepthPassShaderRD' (group 0) SHA256: 50cb1c922c840f610233f20009f23a81457ee61a0e4986a85e5c08a63ef7c6cf
Shader 'Fsr2LockPassShaderRD' (group 0) SHA256: d6dbbf3057a3df42cf35700040550925b590fa22b318da4e9dde695a9c9601bd
Shader 'Fsr2AccumulatePassShaderRD' (group 0) SHA256: 22be82431e6f4ca678118ab070b427f8ab2bac9cf229056893e06dbcf9b88115
Shader 'Fsr2RcasPassShaderRD' (group 0) SHA256: 618153e882d42170c18f28a260da6d5c589acded5900975af70585065a59e085
Shader 'Fsr2ComputeLuminancePyramidPassShaderRD' (group 0) SHA256: 9dcae72fdad619f6b0b4df518e764e82400773504dc6dc42dee94342522a2cb6
Shader 'Fsr2AutogenReactivePassShaderRD' (group 0) SHA256: 309b444059a2b40ba093bf12cc4b01b327ea377105f38fd3c9b62395b068c3e0
Shader 'Fsr2TcrAutogenPassShaderRD' (group 0) SHA256: c0cd163bbfd61c6a3eb0b3dd9ce53a8191ed96d9c49f766122816258c829426a
Shader 'SsEffectsDownsampleShaderRD' (group 0) SHA256: 33191663db775b3239324c8e7c70b322003c7ba4f3bf509584e1cdc8ce90ca14
Shader 'SsilShaderRD' (group 0) SHA256: 7fd8e5f50a5704489ee2a7c2a433125ad7fa0d3a259d399af638bce1edcb8450
Shader 'SsilImportanceMapShaderRD' (group 0) SHA256: 673bf3ed83df4540ff07c5b6592d8117847d322f44fc54c541a41052868672ad
Shader 'SsilBlurShaderRD' (group 0) SHA256: c4823d0e827d0dd34f66eeeb04a52753c801e7a782e63057003523827a7ebfac
Shader 'SsilInterleaveShaderRD' (group 0) SHA256: 18f771bd553cb304db576babd51d4c4cc63df20ac2052fb0e4133f9fbdf5aa3e
Shader 'SsaoShaderRD' (group 0) SHA256: 21e4ef08ca2c349ce5ab040c40233a23516ece7c756639d914d6617b909985b7
Shader 'SsaoImportanceMapShaderRD' (group 0) SHA256: fc0834566ddf20cc312e6a1eafc6e4ead6ebc5874b1beec4f8b7100879adf9b9
Shader 'SsaoBlurShaderRD' (group 0) SHA256: 6649d2399f3866ffbde70be4eae7644fbfe70907923fd36a10552342f768b48d
Shader 'SsaoInterleaveShaderRD' (group 0) SHA256: 1420d433267675277657dbe4a189eb1a8ee79b1dfbd47038e6acf926e1b3b91b
Shader 'ScreenSpaceReflectionScaleShaderRD' (group 0) SHA256: c17a8a99b2bfaf1a0e3fdeaf2afc912e685a8f581ca9ad3208b2637c78d43699
Shader 'ScreenSpaceReflectionShaderRD' (group 0) SHA256: b5d41ffd66ed21e4cb5bb10d7d6c9f1b2575907979e8577ecaadc91765c64733
Shader 'ScreenSpaceReflectionFilterShaderRD' (group 0) SHA256: 60f8b0befc8ae01c09adc3d4b34f7900bc1430b089054913d923605e7a0ca9c4
Shader 'SubsurfaceScatteringShaderRD' (group 0) SHA256: 91e1ac945dad61f48411d0a1244e6636634e9785333c014ac318fcee04b72741
Shader 'SkyShaderRD' (group 0) SHA256: c773b40a48cb349a2f34006aace7b0ef1aaa8fad530160990a9634fcf019aebe
Shader 'VoxelGiShaderRD' (group 0) SHA256: 26adaa157a0dbc77aaeb10cd9840a3cfeddb4699002202c4069ea0aca1b684eb
Shader 'VoxelGiDebugShaderRD' (group 0) SHA256: 10e6f56ab62c32c6283301052f7f3efd8733a2dd8c54b5c8e8875b4019be3530
Shader 'SdfgiPreprocessShaderRD' (group 0) SHA256: 5d3bf192407ce0131d8d17e264d302c13eb17f8284e643e96071c3c2f09b45a8
Shader 'SdfgiDirectLightShaderRD' (group 0) SHA256: 2d9e0cdb42a45dcec8d6fa71bc0e820405887a0f06b540f9cfb9a3d5b0d05c53
Shader 'SdfgiIntegrateShaderRD' (group 0) SHA256: 15a2e64db17d8aafc8f3d8d2a528747c64d294e8034e7b9e4e86e5ee994d66c2
Shader 'GiShaderRD' (group 0) SHA256: fc70dbaf4b894ea97a0300ec38724bb52936be2bd53a8e3d056f28d9938a1c87
Shader 'SdfgiDebugShaderRD' (group 0) SHA256: 1d7fbd21ccb6e9825acc51d893c06bb4030178286b008b840821fd317fc5302b
Shader 'SdfgiDebugProbesShaderRD' (group 0) SHA256: 90121919d39f8150a9149d5e7eca75d0f2b06d679f544f696bdb941a6cf51810
Shader 'VolumetricFogShaderRD' (group 0) SHA256: c6ff2f4ac52f1179cd0f6c29737304d12ed6b90feae4187f34b38d5228ae1765
Shader 'VolumetricFogProcessShaderRD' (group 0) SHA256: 8d17101913be2888afe1d04fa9287ce1137a8385e86202f4b2a3c6946d3d8982
Shader 'BokehDofShaderRD' (group 0) SHA256: c8b02e9d9aed942a821d35f533288d4fd0a2faaf2c7b58b53c8a92c6c3544feb
Shader 'CopyShaderRD' (group 0) SHA256: b3d9672c50ef509a18599d840e170b4531f88fdffb8f3b73d085bf572599743d
Shader 'CopyToFbShaderRD' (group 0) SHA256: 100799ce54eea0950d2a761842afbdb825c4274cd7ae712042a99dd1738b306b
Shader 'CubeToDpShaderRD' (group 0) SHA256: 660d8fbdedf9d936fc5b9136a097854da9e921113edfdd404a556bcd4fad6f8a
Shader 'CubemapDownsamplerShaderRD' (group 0) SHA256: 7fa47c7b9bdb49d907907d1270a1c655307ed89c6d440c039a74c00a0f65519e
Shader 'CubemapFilterShaderRD' (group 0) SHA256: 1f5612e43bd985ba7545d1f652d72bb4a8251a8320475ebca00f62518d75f98b
Shader 'CubemapRoughnessShaderRD' (group 0) SHA256: 10ad3612c713073a9477ce1395ccb37e510a332370ed0c0a810e1a066533c13a
Shader 'SpecularMergeShaderRD' (group 0) SHA256: fee8ef8ea7ed18eeeebcfa2a626d54c6a503d5b75a9d775d7fb17a7e2dddc698
Shader 'ShadowFrustumShaderRD' (group 0) SHA256: 12fb0f35abe27d7c2578b5bdeaf4517d45f710f9b66ab66f57794d77f90c2fd5
Shader 'MotionVectorsShaderRD' (group 0) SHA256: ca45f570f7b085fd508662270a09a17e42436227dd37e8f5a22034bbb70d8a94
Shader 'LuminanceReduceShaderRD' (group 0) SHA256: ad94b0824e25b988f4792cd9be4cb80f042918016d83b4d9683034bbeffdd811
Shader 'TonemapShaderRD' (group 0) SHA256: 886811888c9b1fc45eecfdd383f8c7087ea62f74178fadb6ff561a568aade71b
Shader 'VrsShaderRD' (group 0) SHA256: b747acdb722b2faf724266877a5336a0141453c1632b280cdff87b47c108f7c9
Shader 'FsrUpscaleShaderRD' (group 0) SHA256: 5d97f0e27e6b49e530b561b06452e04bbf6b4763e0b831ea8650c098644f446a
Shader 'BlitShaderRD' (group 0) SHA256: 72c6e59fbd6bdca88a055003cd3614ebdbc4b9fed5efefb796128c188d379986
WASAPI: Activated output_device using IAudioClient3 interface
WASAPI: wFormatTag = 65534
WASAPI: nChannels = 8
WASAPI: nSamplesPerSec = 44100
WASAPI: nAvgBytesPerSec = 1411200
WASAPI: nBlockAlign = 32
WASAPI: wBitsPerSample = 32
WASAPI: cbSize = 22
WASAPI: mix_rate = 44100
WASAPI: fundamental_period_frames = 441
WASAPI: min_period_frames = 441
WASAPI: max_period_frames = 441
WASAPI: selected a period frame size of 441
WASAPI: detected 8 channels
WASAPI: audio buffer frames: 441 calculated latency: 10ms
 
TextServer: Primary interface set to: "ICU / HarfBuzz / Graphite (Built-in)".
CORE API HASH: 915626997
EDITOR API HASH: 1313472085
MbedTLS: Some X509 certificates could not be parsed (1 certificates skipped).
Loaded system CA certificates
GDScript: Reloading all scripts
GDScript: Found: res://temp/mem_burger.gd
GDScript: Found: res://char/ball.gd
GDScript: Found: res://script/HUD.gd
GDScript: Found: res://script/wall.gd
GDScript: Found: res://char/jen/DATK.gd
GDScript: Found: res://char/jen/ATK.gd
GDScript: Found: res://char/jen/TAUNT.gd
GDScript: Found: res://char/jen/PARRY.gd
GDScript: Found: res://char/jen/SUPER.gd
GDScript: Found: res://script/move.gd
GDScript: Found: res://script/game.gd
GDScript: Found: res://script/global.gd
GDScript: Reloading: res://temp/mem_burger.gd
GDScript: Reloading: res://char/ball.gd
GDScript: Reloading: res://script/HUD.gd
GDScript: Reloading: res://script/wall.gd
GDScript: Reloading: res://char/jen/DATK.gd
GDScript: Reloading: res://char/jen/ATK.gd
GDScript: Reloading: res://char/jen/TAUNT.gd
GDScript: Reloading: res://char/jen/PARRY.gd
GDScript: Reloading: res://char/jen/SUPER.gd
GDScript: Reloading: res://script/move.gd
GDScript: Reloading: res://script/game.gd
GDScript: Reloading: res://script/global.gd

Nothing really interesting here.
Ok. Do some test additional func, like

func _unhandled_key_input(event: InputEvent) -> void:
  if Input.is_physical_key_pressed(KEY_Q):
    $fs.stop()
    # Here copy code about how `rand` generated
    $fs.stream = load("res://sound/fs" + str(rand) + ".mp3")
    $fs.play()

then run game, press Q many times and see how memory will grow, or not.
Resources (like mp3/wav), when not loaded somewhere - automatically unload. Think may be you store copy of $fs, idk may be with player 2

Mashing Q doesn’t make memory grow at all.

I removed every single use of load() and it still happens. The mechanics I suspected were causing this issue were also disabled entirely and it still happens. Tabbing in and out of the game or simply having it visible when holding alt+tab also increases memory. Is my game just screwed or is there something deeper going on here? I’m running into so many issues and it’s putting me off even trying anymore

Can you show your ball-interaction in code?

1 Like

On a long shot…how sure of you of your memory calculation?

The code probably sucks but here it is:

extends CharacterBody3D

var speed = 0.0
var angle = 0.0
var direction = Vector3.ZERO
var tagged = -1
var buffered_speed = 0.0

@onready var stall_detect = $StallDetect

var hit_sounds = { # did this instead of load(), no difference. :(
	"small": {
		"new": [
			preload("res://sound/althitsmall1.mp3"),
			preload("res://sound/althitsmall2.mp3"),
			preload("res://sound/althitsmall3.mp3"),
			preload("res://sound/althitsmall4.mp3")
		],
		"old": [
			preload("res://sound/hitsmall1.mp3"),
			preload("res://sound/hitsmall2.mp3"),
			preload("res://sound/hitsmall3.mp3"),
			preload("res://sound/hitsmall4.mp3")
		]
	},
	"mid": {
		"new": [
			preload("res://sound/althitmid1.mp3"),
			preload("res://sound/althitmid2.mp3"),
			preload("res://sound/althitmid3.mp3"),
			preload("res://sound/althitmid4.mp3")
		],
		"old": [
			preload("res://sound/hitmid1.mp3"),
			preload("res://sound/hitmid2.mp3"),
			preload("res://sound/hitmid3.mp3"),
			preload("res://sound/hitmid4.mp3")
		]
	},
	"large": {
		"new": [
			preload("res://sound/althitlarge1.mp3"),
			preload("res://sound/althitlarge2.mp3"),
			preload("res://sound/althitlarge3.mp3"),
			preload("res://sound/althitlarge4.mp3")
		],
		"old": [
			preload("res://sound/hitlarge1.mp3"),
			preload("res://sound/hitlarge2.mp3"),
			preload("res://sound/hitlarge3.mp3"),
			preload("res://sound/hitlarge4.mp3")
		]
	},
	"ultra": {
		"new": [
			preload("res://sound/althitultra1.mp3"),
			preload("res://sound/althitultra2.mp3"),
			preload("res://sound/althitultra3.mp3"),
			preload("res://sound/althitultra4.mp3")
		],
		"old": [
			preload("res://sound/hitultra1.mp3"),
			preload("res://sound/hitultra2.mp3"),
			preload("res://sound/hitultra3.mp3"),
			preload("res://sound/hitultra4.mp3")
		]
	}
}

var last_hit_by = -1

signal goal(player)

func _ready():
	set_direction_from_angle(angle)
	self.show()
	$CollisionShape3D.set_deferred("disabled", false)
	$Collision/CollisionShape3D.set_deferred("disabled", false)

var ticks = 5

func _physics_process(delta):
	
	if $Collision/CollisionShape3D.disabled:
		$StallDetect/CollisionShape3D.set_deferred("disabled", true)
	else:
		$StallDetect/CollisionShape3D.set_deferred("disabled", false)
	
	if speed > 5:
		if ticks > 0:
			ticks -= 1
		if ticks <= 0:
			if Global.decay and !Global.cooldown:
				speed *= Global.decay_rate
			ticks = 5
			
	if speed <= 5:
		if speed != 0:
			speed = 5
	
	velocity = direction * speed
	
	move_and_slide()
	check_wall_collisions()
	
	if tagged != last_tag:
		update_ball_tag()
		last_tag = tagged
	
	$Label3D.text = str(tagged)
	
	if Global.debug:
		if Input.is_action_just_pressed("debug"):
			Global.players[0].sp = 100 # fill p1's sp meter :D :D :D
			

func set_direction_from_angle(angle_degrees):
	var angle_radians = deg_to_rad(angle_degrees)
	direction.x = cos(angle_radians)
	direction.z = -sin(angle_radians)

func check_wall_collisions():
	for i in range(get_slide_collision_count()):
		var collision = get_slide_collision(i)
		if collision:
			var normal = collision.get_normal()
			$wall.pitch_scale = 0.9 + randf() * 0.2
			$wall.play()
			if abs(normal.x) > abs(normal.z):
				direction.x = -direction.x
			else:
				direction.z = -direction.z
			break

var p1_hit = false
var p2_hit = false

func _on_collision_area_entered(area):
	
	if area.name == "PARRY" and speed > 0 and area.attacker != tagged:
		$parried.pitch_scale = 0.9 + randf() * 0.2
		$parried.play()
		set_direction_from_angle(0)
		speed = 0
		tagged = -1
		$parryrandtimer.start()
		Global.players[area.attacker].parry_cancel = true
		position.x = Global.players[area.attacker].position.x
		if area.attacker == 0:
			position.x += 1
		else:
			position.x -= 1
			
		position.z = Global.players[area.attacker].position.z
	
	if area.name != "WallArea" and !area.name.begins_with("Goal") and !area.name == "hurtbox" and area.name != "PARRY":
		if area.attacker == 0 and !p1_hit or area.attacker == 1 and !p2_hit:
			print(area.name)
			print(area.attacker)
			
			if Global.tagging:
				tagged = area.attacker
			
			# increase attacker's sp
			if Global.players[area.attacker].sp != 100:
				if area.name == "ATK":
					Global.players[area.attacker].sp += 2
				elif area.name == "DATK":
					Global.players[area.attacker].sp += 4
				elif area.name == "TAUNT":
					Global.players[area.attacker].sp += 1
			
			$hit.stream = hit_sounds[area.sound][Global.sfx_type][randi_range(0,3)] # get and play random hit sound from preloaded assets
			
			if Global.sfx_type == "alt": # adjust volume for alt sounds so you don't go deaf
				$hit.volume_db = 5
			else:
				$hit.volume_db = 10
				
			$hit.pitch_scale = 0.9 + randf() * 0.2
			$hit.play()
			set_direction_from_angle(area.angle)
			
			if Global.old_speed:
				speed = area.power
				print("old speed")
			else:
				speed += area.power
				print("no old speed")
			
			if area.attacker == 0:
				p1_hit = true
			else:
				p2_hit = true
			
	elif area.name.begins_with("Goal"):
		speed = 0
		angle = 0
		kill_ball()
		if area.name == "GoalLeft":
			Global.scores[1] += 1
			emit_signal("goal", 1)
		elif area.name == "GoalRight":
			Global.scores[0] += 1
			emit_signal("goal", 0)

func _on_collision_area_exited(area):
	if area.name != "WallArea" and !area.name.begins_with("Goal") and area.name != "hurtbox" and area.name != "PARRY":
		if area.attacker == 0:
			p1_hit = false
		else:
			p2_hit = false

func kill_ball():
	self.hide()
	$CollisionShape3D.set_deferred("disabled", true)
	$Collision/CollisionShape3D.set_deferred("disabled", true)

func reset():
	self.show()
	$CollisionShape3D.set_deferred("disabled", false)
	$Collision/CollisionShape3D.set_deferred("disabled", false)

func _on_parryrandtimer_timeout():
	if tagged == -1:
		$whee.play()
		set_direction_from_angle(randi_range(0,360))
		speed = 5
	else:
		print("ball tagged, no punish here")

var last_tag = -1

func update_ball_tag():
	if tagged == -1:
		$mesh.mesh.surface_get_material(0).set_shader_parameter("base_color", Color.html("ffffff"))
	elif tagged == 0:
		$mesh.mesh.surface_get_material(0).set_shader_parameter("base_color", Color.html("ff0000"))
	elif tagged == 1:
		$mesh.mesh.surface_get_material(0).set_shader_parameter("base_color", Color.html("0051ff"))
	

I disabled the stall timer and the player hit mechanic as it seemed to happen a ton when those were in play. Same thing kind of happens though, plus tabbing in and out?? That shouldn’t increase memory use, right? This only happens to this extreme degree when the game is maximised. Here’s another video showing more memory issues:

100% certain it’s accurate, in task manager and in the monitors tab the same can be seen just a lot slower. I threw it onto a label so I could see the memory exploding in real time.

hm code is not very suspicious. My only idea is that its the shader maybe? Turn off the shader logic and try again

Disabled every shader and the same happens. It’s really weird because it happens when the ball is moving, but there’s nothing dodgy going on in the code that makes the ball move??

It does kind of seem to correlate with text updates. Kind of.

As to the CharacterBody3D code, I would make that dictionary a constant unless you are wanting to change its members at runtime.
I assume that both players will use this CharacterBody3D script and if so there is no need for each of them to own the sound effects. You might consider moving that out of there.
These two things however, are not related to your memory issue.

1 Like

you can try to export the game and see if it also happens in the exported game or just inside the editor

As in the labels for HP, ball speed, round time, stall time, etc?

The CharacterBody3D code is for the ball itself but I’ll make the sound dictionary a constant now.