Deathmax/TerrariaAPI-Server — pull request #31 by MarioE (2013-12-03 03:39:19+00:00)
Title: More efficient RAM usage

These commits make RAM usage drop dramatically -- it roughly halves the amount of memory used, or more on Mono.

Main.tile is now a TileCollection with a get/set indexer which returns a helper struct (not a class, as a class proved to be *far* too slow due to allocation on the heap instead of stack). Properties couldn't be implemented on the struct due to the "Cannot modify the return value because it is not a variable". Thus, all instances of Tile.frameX, frameY, liquid, type, and wall had to be regex replaced, and a method had to be used. This means that compatibility with plugins that deal with tiles is broken, but I believe the gains are far, far more than the losses incurred by this.

ServerSock.writeBuffer has been removed because it is never used, which saves 256KB of RAM. messageBuffer.readBuffer has been lowered to 1KB instead of 64KB because ServerSock.readBuffer can only hold 1KB, which saves ~16 MB of RAM.

Various client-based classes have been removed entirely, also helping the RAM usage.

Finally, several files have been replaced with files generated from bc's ILSpy, which means that there are no longer millions of tabs in them.