7

I’m writing an application that instantiates many large array buffers, some of which are 5MB. I would like to know when I’m about to fill up the javascript heap, so I could activate a condition in my javascript that halts allocating the buffers. I’ve found that if I do exceed the heap size, the browser crashes for Chrome and Firefox.

Does W3C expose an interface for gauging javascript heap usage?

John Hoffman
  • 17,857
  • 20
  • 58
  • 81
  • I'm going to take a stab and say no, but since I don't know for sure, I'm leaving this as a comment. The fact that you can't gain access to the FileSystem because of security makes me highly doubt that you'd have access to the memory or other internals. However, I'm curious if you could fail nicely without browser crashing, if not by using `try`/`catch` to allocating space. – vol7ron Nov 12 '14 at 18:53
  • The W3C isn't the standards body for the language, it's primary activity is to [*…is to develop protocols and guidelines that ensure long-term growth for the Web*](http://www.w3.org/Help/#activity), so no. [*ECMA-262*](http://ecma-international.org/ecma-262/5.1/) (the underlying language specification) doesn't define implementation details, so it doesn't specify any way to determine "heap usage" either. – RobG Nov 12 '14 at 19:03
  • 1
    http://stackoverflow.com/a/23705446/183181 Seems like there's a Chrome way – vol7ron Nov 12 '14 at 19:05

1 Answers1

2

Nope.

The JavaScript (ECMA-262 5.1 Edition) language specifies no such functionality.

maerics
  • 151,642
  • 46
  • 269
  • 291