0

I am writing client side applications, but regularly run into an issue whereby I am using to much memory on a lower end device and it stops processing javascript to compensate for this. This appears to be a common 'solution' to this problem on lower end devices.

Is there any reasonable way to detect memory usage and/or limits or when the limit has been reached and scripts are failing, etc.

If I can detect this, I can implement solutions to handle it (like limit caching, more lazy loading, etc.)

Please do not mark my question as duplicate to a question whose only answers are about how to detect memory usage and not about estimating memory limitations!

user2765977
  • 491
  • 4
  • 18
  • If this is becoming a problem then consider using things to lower memory for all your users as everyone should see a performance bump, e.g. a single image for all your sprites, sharing memory instead of duplicating things, etc etc – Paul S. Jun 25 '15 at 14:00
  • Not really that article deals with detecting memory usage, I'm more interested in figuring out if you are hitting memory limits. – user2765977 Jun 25 '15 at 14:01
  • 1
    @Paul: All that is already done. I am trying to figure out how much caching, etc. I can get away with. (all the optional memory stuff) – user2765977 Jun 25 '15 at 14:02
  • The only way I can think to approach this in javascript is to write a performance function and run it on an interval. Make some haphazard correlation with its execution time and memory usage. Adjust accordingly. – mccainz Jun 25 '15 at 14:28
  • I was also leaning in this direction. I thought of maybe correlating that information in some way with device resolution to make a general assumption of available memory. – user2765977 Jun 25 '15 at 14:37

1 Answers1

0

This might help you:

http://www.monitis.com/blog/2011/05/15/30-tips-to-improve-javascript-performance/

As for page performance:

  1. Use 'Profiles' tab in chrome developer window(press F12 to fire it up)

  2. Firebug profiler in Firefox

arnabkaycee
  • 1,634
  • 13
  • 26
  • 1
    Unfortunately not, I need to determine programtically in the browser when I am using too much memory on things like caching, etc. so that I can put limits in place DYNAMICALLY. – user2765977 Jun 25 '15 at 14:05
  • I am afraid, you cannot do that. JS does not expose such API to do that. Using practices like lazy loading, less looping, using specific selectors, etc are always considered best practices. – arnabkaycee Jun 25 '15 at 14:10