I have a web app using javascript websockets to fetch and render realtime data.The problem is once the websocket connection is established,the memory usage of my browser gradually increases in MBs. Once I close the tab,the memory usage drops by the same amount as it increased. I am rendering the data received through websockets to google chart as well and the data is received every 2 seconds triggering a re-render of the chart with new data.Could that be the issue?Or are websockets causing the rise in memory usage?
I figured out the problem. Thanks @jFriend00 for the guidance.
I assumed the problem to be with websocket after some lazy reading of blogs/posts/articles and posted the question here after that.
I re-checked my code and found that the issue was with re-rendering charts every second.I was creating a new instance of the chart for rendering every second.I was hoping GC would do the job of clearing up the old chart but it wasn't so.
I modified my code to clear the existing chart and render the same with new data and Voila! my memory consumption is back to normal.