xspanger3770 / GlobalQuake

Experimental application for monitoring earthquakes world-wide in near real time. Capable of issuing its own earthquake early warnings (EEW).
MIT License
281 stars 41 forks source link

Fix memory leak in object streams by reusing the same packet instance #285

Open PopSlime opened 2 months ago

PopSlime commented 2 months ago

Description

Instances of HeartbeatPacket and EarthquakesRequestPacket are sent periodically during a connection. However, these two record classes carry no additional information, so it is safe to reuse a single instance for each of them. As ObjectInputStreams and ObjectOutputStreams track all instances involved in them, this can improve memory usage of the application.