PSA: Connections can memory leak Instances!


I’ll probably keep using lowercase connect myself until they start throwing warnings for it in intellisense. It’d be too weird to switch otherwise.



I use :connect because that way my eyes will focus on the PascalCased event name. Of course, we’re going off topic here, but…

1 Like


I prefer :connect() in my code



The only issue with using :connect() versus :Connect() is being forced later to change it all. For now they are exactly the same, but if some kind of major issue is discovered/new method is applied, it will be applied to Connect and not to connect. Using the lowercase version is like sticking to an old OS; it still will work, but over time it can get more and more out of date, potentially exposing flaws or lacking features that are actually required. In the end it is a matter of change now with little effort, or change later with a ton of effort.

1 Like


Both Connect and connect point to the exact same function in memory.



That is exactly what I said.

1 Like


No it won’t. If it applies to Connect, it’ll automatically apply to connect. They point to the same function in memory. Your statement would be true if they both pointed to different, identical functions.



They do point to the same for now, if an update happens Connect will be updated to point to the new method.



No it won’t. They both point to the same function in memory. If Connect needs updating, they’ll update that function. Because connect also points to that function, it’ll be updated too. The only way to get your scenario is if they duplicated the function, changed it, then changed Connect to point to that. That won’t happen because it’s easier to just change the original function that Connect and connect already point to.



The way a wiki writer on the late Roblox scripting forum described it (trying to find the post without much luck right now), they are keeping ‘connect’ the way it currently is. If any changes happen, they happen to Connect by making it a new method, while connect refers to the thing it always refered to.



Was the wiki writer an official staff member? They’d never do that because it’s asinine.

The way it works is kinda like this. (Similar only in behaviour, the actual code is of course in Lua C and in a different format, but the idea is the same)

local function handleConnect(...)

hookMethod("Connect", handleConnect)
hookMethod("connect", handleConnect)

Thus, when they want to change the behaviour of Connect, they’d just edit that handleConnect function, which will automatically change both.

It’s more effort on Roblox’s part to have different behaviour.

Similar to how service has always worked the same as GetService, Workspace to workspace, children to GetChildren, etc.

1 Like


Pretty sure it is not handled in Lua at all, they merely change the global ‘Connect’ to refer to a different C-method in the API. That is not a lot of effort, and for backwards-compatibility reasons not entirely uncommon practice either. Similar to Destroy and Remove, they did not change Remove’s behavior but instead introduce Destroy as expanded version. It is a design choice more than anything else and has nothing to do with workspace being a shorthand global variable.



It’s not handled in Lua, I said that. I put it in Lua to simplify it to get the point across.

Destroy and Remove are completely different functions that do completely different things for a reason. They were never promised to be aliased to each other. They have non-similar names.

They’ve never done anything like what you’re suggesting with :service, :children, :findFirstChild, etc.



As far as I am aware Lua C is not a thing either, C is C no matter whether you include a Lua.h lib.

In the end since I can not provide the post mentioning the difference as opportunity to alter behavior it is merely speculating whether either side is likely to happen, the only real thing to bear in mind is that deprecation is defined as

“In several fields, deprecation is the discouragement of use of some terminology, feature, design, or practice, typically because it has been superseded or is no longer considered efficient or safe, without completely removing it or prohibiting its use.”

From the definition and the fact connect is listed such, it is safe to assume it will not be changed anymore, which in fact is not a given for connections as a whole. Since Connect is not deprecated, I do find it likely only that will be updated to reflect potential changes.



You are misinterpreting what I’m saying. Lua C is C with the Lua API. You know what I meant.

Again, they’re not going to change Connect but not connect. It’s more effort to do so, and they’ve never done it for any other deprecated method.



Let’s keep this thread on topic please. Speculating about updates is not the topic of this tutorial.



Haha rip me, I was clearing workspace inbetween rounds by using :remove instead of :destroy()
Hopefully now that I destroy items it’ll clear up some memory.




This might have just saved my life. Thank you



To think I’ve been using :remove blissfully throughout the whole of my life…

I’m gonna miss you buddy.



Yeah, I stopped using :remove() as soon as I found out about the difference between the 2.