admin管理员组

文章数量:1320864

This is the fiddle: /

After about 10-20 seconds, the display starts to freeze randomly and shortly after crashes. I cannot reproduce this in Firefox.

Profiling reveals nothing unusual.

/ shows there is definitely a memory leak. Even a 1 FPS, the memory usage climes 5 megabytes a frame.

On a side note, this example really shows how Math.random() is really not so random.

This is the fiddle: http://jsfiddle/36mdt/

After about 10-20 seconds, the display starts to freeze randomly and shortly after crashes. I cannot reproduce this in Firefox.

Profiling reveals nothing unusual.

http://jsfiddle/3pbdQ/ shows there is definitely a memory leak. Even a 1 FPS, the memory usage climes 5 megabytes a frame.

On a side note, this example really shows how Math.random() is really not so random.

Share Improve this question edited Jun 14, 2012 at 16:19 trumank asked Jun 14, 2012 at 15:48 trumanktrumank 2,7943 gold badges23 silver badges31 bronze badges 15
  • 3 I don't have an answer yet, but that visual effect is freaking AWESOME... :) – chrisfrancis27 Commented Jun 14, 2012 at 15:52
  • 4 Did you notice that after 10 seconds, it's using 1.2GB of memory – Esailija Commented Jun 14, 2012 at 15:52
  • @Esailija The task manager shows that, but profiling shows no change...? – trumank Commented Jun 14, 2012 at 15:54
  • @MathWizz what do you mean by profiling – Esailija Commented Jun 14, 2012 at 15:54
  • @Esailija The "Profiles" tab in the Chrome console. – trumank Commented Jun 14, 2012 at 15:56
 |  Show 10 more ments

3 Answers 3

Reset to default 3

I've done only 2 performance improvements and it doesn't crash after 5 mins (also seems to be not leaking memory). Checkout http://jsfiddle/3pbdQ/3/

  1. Don't calculate the size inside each iteration
  2. Use timeouts instead of freezing interval.
  3. Use bitwise operator for flooring a number

Profiling reveals nothing unusual.

Chrome Profiler doesn't work with WebWorkers, AFAIK. As per conversation with Paul Irish:

"Check about:inspect for shared workers, also you can do console.profile() within the worker code (I THINK) and capture those bits. The "cleans up" is the garbage collector: if after the cleanup there is still a growing line of excess memory, then thats a leak."

And

On a side note, this example really shows how Math.random() is really not so random.

It is well known there are no perfect random algorithms, but anyway the bunch of grouped colors you see is because you're not setting canvas.height and canvas.width, and it differs from CSS values.

EDIT: Still leaking memory, I don't know why, about after 10 secs it 'cleans up'. Exceeds my knowledge, but works smoothly at 60 FPS (var TIME = 16)

Depending on the system and browser version you use some steps may vary although I tried my best to provide mon steps that are patible with most systems.

Disable Sandbox: 1. Right click Google Chrome desktop icon. 2. Select Properties. 3. Click Shortcut > Target. 4. Add "--no-sandbox" 5. Click Apply | OK. 6. Download and install ZombieSoftFix. 7. Check and resolve conflicts detected.

Disable Plug-Ins: 1. Type "about:plugins" in Address Bar. 2. Press ENTER. 3. Disable all plug-ins displayed in the list page.

Clear Temporary Files: 1. Click Wrench. 2. Select More Tools | Clear browsing data. 3. Check-up all boxes, click "Clear browsing data" button to confirm the process.

Thanks & Regards.

This is an unfortunate, known Chrome bug.

本文标签: JavaScript freezingcrashing in ChromeStack Overflow