Question about memory leak caused by local connections

Provide an overview of:
Right now I made a function that creates a bunch of proximity prompts locally and adds a connection to them

function module.AddPlacePrompts()
	local CharacterStandsModel: Model = CoreFunctions.ReturnPlayerStand(player)
	local PlacePrompt = ReplicatedStorage.ProximityPrompts.PlacePrompt
	for i, StandPart in pairs(CharacterStandsModel:GetChildren()) do
		local PromptClone = PlacePrompt:Clone()
		PromptClone.Parent = StandPart
		PromptClone.Enabled = false

		PromptClone.Triggered:Connect(function()			
			Signal.FireServer("PlaceCharacter", StandPart)
		end)

	end
end

because These proximity prompts are only made locally so only the player can activate them I was wondering if these would cause a memory leak if the player left because of the leftover triggers or if the proximity prompts and triggers would be automatically deleted

it’s possible for a memory leak to happen when you give info to the server from the client and the server doesn’t handle it properly

if you are really that worried then add each prompt to a table then add a function to read, write and remove from it. it shouldnt be that worrisome other than the fact you are using pairs() wrong but seems fine for now.

If the Prompts & Connections are made on the player’s client only, and the player leaves, all of that data only exists on the player’s client and therefore will be consumed by the void when their application closes. It will never exist for the server / other players :slight_smile:

2 Likes