2

I'm having some issues with garbage collection in Chrome. I have some AJAX code that retrieves a large number of objects from a web service (in the tens of thousands), and it then transforms the data into various objects. At some point shortly after the response is received, the JS hangs for around 7 seconds while Chrome does garbage collection.

I want to delay GC until after my code finishes running. I thought saving a reference to the original JSON objects that were returned by the service and then disposing of it later would do the trick, but it hasn't had any effect, the GC still occurs right after the AJAX response arrives. When I try to take a Heap Snapshot, to verify this is what's causing the GC, Chrome crashes (something it's really good at doing, I might add...)

A couple related questions:

  • Does Chrome not use a separate thread for GC?

  • Is there anything I can do to delay the GC until after my code has finished running?

MgSam
  • 12,139
  • 19
  • 64
  • 95
  • i recently found a same question,and tried to answer it.Let me search..it may help you. – HIRA THAKUR Jul 18 '13 at 20:55
  • Are you updating the DOM after the AJAX call? In most webapps, changing the DOM is the bottleneck. The general fix to that is to calculate all the DOM changes you are going to make and perform one DOM update instead of in a loop. Do you have some example code to look at, like a link to a jsfiddle? – jcbelanger Jul 18 '13 at 20:56
  • @cereal77killer Unfortunately, I have no code to show. It's a very big, complicated app. – MgSam Jul 18 '13 at 21:01
  • Can you provide a simple example of the code that will demonstrate the code in question? – jcbelanger Jul 18 '13 at 21:18

0 Answers0