Are there techniques to reduce the use of memory (on the part of development) regarding the use of javascript?

Asked

Viewed 66 times

0

I would like to know if there is any technique to reduce the use of memory as to the use of javascript. I mean, as to development.

I noticed that a certain page that we are developing where I work seems to use a lot of memory, and this is flagged in google Chrome as being most of this consumption coming from javascript.

How could I solve this?

  • 2

    Wallace, taking into account your history, I will say something I believe you are already doing: try to decrease the number of queries to page elements, reduce the number of functions in memory, you can achieve this by declaring them at the beginning of the scope.

  • 1

    I wouldn’t know where to begin with that answer. But surely the problem is because it’s keeping objects too active for longer than is actually needed.

  • @bigown, for example, my application carries posts under demana (inifinite scroll). It seems that with each "scroll" of mouse, the memory only increases absurdly as to consumption

  • First, when you carry too much, it is normal that consumption increases. There is no miracle. But it certainly has certain ways of doing this so there’s no waste and ways in which it duplicates or multiplies data unnecessarily. Then we start to get into specific situations.

  • Try using more pure javascript (I don’t know if this is your case of using too much jQuery) for simpler operations, like loops for example. From an attention to how you create events to large groups of elements or how you manipulate these elements, that sort of thing.

1 answer

0

This is an architectural problem. What I would do is to do a new step of surveying requirements. It may be that there are events where there is waste of functions, objects, etc. Try to make requests via GET to receive only the functions you need. Be careful when making use of JSON loading. Taking care simpler than it looks, it will not overload the hardware at the time of application.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.