Is this a memory leak? Script activity rate increasingly high

Hello, I’m having an issue that’s been giving me a headache for a few hours already.

So, I have a collector that collects drops every time it gets touched, this will fire a BindableEvent to update the values of UIs and such.

[SERVER]

I have debugged and eventually got to these 2 functions:

function Tycoon:PublishTopic(topicName, ...)
	self._topicEvent:Fire(topicName, ...)
end

function Tycoon:SubscribeTopic(topicName, callback)
	local connection = self._topicEvent.Event:Connect(function(name, ...)
		if name == topicName then
			callback(...)
		end
	end)
	return connection
end

The :PublishTopic event creates some sort of memory leak for some reason as seen below.

When I comment the line that fires the event, it seems to no longer increase the rate.

function Collector:OnTouched(hitPart)
	local Worth = hitPart:GetAttribute("Worth")
	if Worth then
		--self.Tycoon:PublishTopic("WorthChange", Worth)	
	end
end

Also, it seems to work perfectly fine when testing in studio, but when I go in-game, the rate keeps increasing forever.

Does anyone have any idea why this happens? I can’t seem to figure it out.
Any help is appreciated, thanks.

Bit late of a reply, but it looks like you’re experiencing a bug in Roblox’s engine. You can tell if its a bug if the rate is really high but there is no effect on the servers performance
The bug happens pretty randomly in my experience but you should be looking at the Activity(%)

You can check memory being used with collectgarbage("count") if its higher than 2000 or something like that somethings going on

1 Like