3

I'm working on a memory intensive web app (on the order of several hundred megabytes to a gigabyte or more) and I'm trying to figure out what my options are for memory management. There doesn't seem to be any way to figure out if my application is approaching the memory limit of the browser / Javascript engine, and once the app exceeds that limit the browser just crashes. I could just be super conservative with the amount of memory I use in order to support browsers running on low end machines, but that will sacrifice performance on higher end machines. I know Javascript was never designed to be able to use large amounts of memory, but here we are now with HTML5, canvas, WebGL, typed arrays, etc and it seems a bit short sighted that there isn't also a way in Javascript to determine how much memory a script is able to use. Will something like this be added to browsers in the future, or is there a browser specific API available now? What are my options here?

Update

I'm not sure that it matters, but for what it's worth I'm displaying and manipulating hundreds of large images, in file formats not supported by web browsers, so I have to do all of the decompression in Javascript and cache the decompressed pixel data. The images will be displayed on a canvas one at a time and the user can scroll through them.

Dave A
  • 484
  • 3
  • 10
  • 1
    Not sure whether there is an API for RAM consumption like there is for storage. Out of curiosity, what is your app doing that needs that kind of resources on client side in the first place? – Pekka Dec 19 '13 at 23:36
  • If you state what your app really is, what does it do, what data it uses, and all the other related detail, we can help you. Otherwise, you won't get a sensible answer. – Joseph Dec 19 '13 at 23:40
  • Javascript is used inside the browser, so it can consume as much memory, as much the browser can consume. There is no way to determine that, not even the browser knows this information. It will consume as much as is available. You just need to make your application use as less RAM as possible (e.g. by deleting off-canvas data after scrolling, reusing object, etc.). Maybe it'd help to assume that all your users will have crappy hardware. AFAIK, there's no easier or more elegant way – foibs Dec 20 '13 at 00:16
  • Related question: http://stackoverflow.com/questions/2530228/jquery-or-javascript-to-find-memory-usage-of-page – jfriend00 Dec 20 '13 at 00:23

0 Answers0