Memory in Chrome keeps rising

Hi all,

I have a Delphi http server that connects with a Chrome client using RemObjects 9.3. When I inspect the memory usage of the client with Chrome’s own task manager I see a constant increase in the memory column. The javascript memory goes up and down as expected. If I understand the documentation correctly this means that extra DOM nodes are created. However, according to the DOMListener plugin no new nodes are created. If I turn of the polling mechanism with the EventReceiver, the memory increase stops. So my suspicions are directed towards the RemObjects javascript client. Does anyone have a similar experience? Should I move to the HttpAPI?

Kind regards and a happy new year

Hello

Seems you are using EventReceiver. HttpAPI has no support for events, so you cannot switch to it w/o redesinging a part of your application.

Could you create a testcase where this behavior reproduces? That would allow us to pinpont the issue.
Or you could investigate what exactly eats the memory unsing this technique: https://developers.google.com/web/tools/chrome-devtools/memory-problems/heap-snapshots

Regards

Hi,

Thanks for the quick reply. I have been looking at those heap snapshots all day. I am none the wiser. I did the “three snapshot” technique (described here, but it pointed to the window variable as the culprit. My linter prevents me from using globals, and I only made exceptions for the RemObjects.SDK itself and my interfaces.

The jumps in memory are quite big: 10k-100k per second.

Unfortunately I cannot show you the actual web site as it involves hardware.

I can attach the snapshots, but these are 40MB each.

I’m afraid these snapshots won’t be useful for me w/o the actual code knowledge (ie w/o a deep undestanding of your app architecture).

So let’s take a usual debugging route:

  1. For the start try to run the HTTP Chat sample shipped in c:\Users\Public\Documents\RemObjects Samples\RemObjects SDK for JavaScript\HTTP Chat and check if the issue reproduces there as well.

  2. Then go to your app and comment out all .addHandler calls for your EventReceiver (btw does it use a separate channel instance?)

  3. Check if the memory issue is still there

  4. Enable handlers one by one until the issue shows again

  5. Then tae a look at the offending event handler method to find out what actually causes the memory leak

I started the .Net chat server and connected with the javascript client. When I monitor the memory in the Chrome task manager, I see it rise (not as quickly as in my app) with 4k or 8k chunks per second. Every now and then it goes down, but the trend is definitely upwards.

My EventReceiver uses the same channel as the rest of the app, so my events and “normal” calls come over the same channel.

I have just one addHandler function. And even when there are no events to handle, the memory increases.

Could also be a garbage collector doing its work in small chunks. However I’ll log an issue to investigate this on the latest Chrome build.

Actually it should use separate channel. Could you check if it makes a diference?

Thanks, logged as bugs://79298

Using a separate channel in my case means I need to create a second session from the same client. That is the only way my SessionID (after connecting) and the ClientID (after signing up for events) are identical. If they are different I get no events.

You may have hit on the problem though… I had a watchdog in my client (getting the server time every second) on the same channel as the polling. I removed that watchdog and things improved. Could this be the cause?

With the two session approach, the memory goes up and down, but does not increase rapidly. I will do more thorough tests in the coming days.

Quite possible.

You need to use different instances of the client channel but the same message instance. In this case both service requests and event receiver should use the same client Id