views:

116

answers:

2

I'm using chrome (the dev version for my mac).

I was looking at the timeline for my page loading and I saw that there is a 150ms delay due to some garbage collection taking place while loading the page.

http://cl.ly/cce10619c698a5b276e2

It's the yellow line.

I was curious if there's any way to stop this, delay it, whatever so I get the page to load faster?

G-Man

A: 

Don't create so much garbage: Look at where your JavaScript program allocates memory during load and see if you can eliminate the garbage collection by reusing data structures or delaying that work until after the page has loaded. This lets you 'delay' garbage collection.

Dominic Cooney
-1 this is not a helpful answer. at all.
Dave DeLong
+2  A: 

Against the grain of some of the comments, this isn't a C++ issue.

Garbage Collection happens when v8 (the javascript engine in chrome) engine detects that it should start freeing up memory used by objects that are no longer needed in the code. You can visit the v8 page for more information about what the garbage collector does.

There might be lots of reasons why your code is garbage collecting early, and in that case we would need to see your code. Do you have a lot of variables that go out of scope at page load?

Kinlan