YoYoGames / GameMaker-Bugs

Public tracking for GameMaker bugs
13 stars 5 forks source link

Memory Management with Sockets Unclear + Note on network_destroy() Outdated? #5878

Open TheGitMagician opened 2 weeks ago

TheGitMagician commented 2 weeks ago

Description

In a conversation with yoyo-danielc on an issue regarding websocket connections (see https://github.com/YoYoGames/GameMaker-Bugs/issues/4447 ) I was made aware that you have to destroy a network socket via network_destroy() when you no longer use it. Otherwise it will cause a memory leak.

This brings up two questions:

1) Usually the manual mentions when things that you create have to be destroyed after their usage to prevent memory leaks. Typical examples are Data Structures or Buffers. However, the manual entries on "Networking" as well as network_create_socket() and network_create_socket_ext() do not mention any memory management issues and don't point to network_destroy(). Should this be added?

2) The manual entry for network_destroy() says: "NOTE: This function will not work when used in a project running on the HTML5 target." yoyo-danielc says that the function should work correctly on HTML5. My own tests also confirm this. Using network_destroy() successfully removes/clears a socket on the HTML5 target. Could this be a leftover from before Websocket support was added to GameMaker? In that case it should be removed.

Manual Link

No response