Closed User670 closed 5 months ago
Batching overnight shouldn't create that many ports unless there's an issue with your code that causes ports to leak. Ports should be cleaned up (removed from that Map) immediately after write if you're using nextWrite to read from it.
I'm tempted to say this isn't a bug because there's no use case for that many concurrent ports. There are countless ways to break the game if you do something dumb (like the Number.isNaN = null;
guy in the discord bug reports channel).
EDIT: Here's exactly where read deletes the port from that Map.
Converted it into a feature request. Closing this one.
To add on to what LJ said: The problem here is that you wrote to each of these ports, but never read from them. As a result, all the data for them can never be cleaned up or reclaimed. If you fix that (which should be possible for any conceivable scenario), the issue goes away.
Scripts to reproduce:
test.js
:worker.js
:Steps to reproduce:
run test.js
NetscriptPorts
(this one) exceeds size limit at this bit hereTraceback:
The test was done on a fork of the dev version (v2.6.1dev, closest main repo commit is 6aaeb6b , I added console.log's in places that don't concern this bug for something else but nothing that affects the game's logic. If needed I'll test on a clean dev version or the stable version), but the issue also happened on my stable version game (Bitburner v2.6.0 (8154a4613))
In case you wonder "why the heck do you have 16M ports" - the answer is batching for overnight sessions.