Greenstand / treetracker-web-map-client

The front end of the treetracker web map app.
http://map.treetracker.org
GNU Affero General Public License v3.0
64 stars 180 forks source link

Optimize the resource consuming of the next.js #1749

Open dadiorchen opened 8 months ago

dadiorchen commented 8 months ago
image

Now the web map client is consuming a lot mem (comparing to our microservice node.js instance), is it possible we can reduce it? Buy settings or other way?

RingoTC commented 6 months ago

I think this issue may be caused by the usage of log.warn in the production environment. loglevel is building upon the console.log. If a variable is created and logged by console.log, it can't be collected by gc of V8. For react, because the repaint, this problem will trigger more frequently. Here are some materials related to this problem.

https://javascript.plainenglish.io/can-console-log-cause-memory-leaks-how-to-make-a-browser-crash-with-console-log-b94e4d248ed8 https://stackoverflow.com/questions/33283446/loop-of-console-log-in-nodejs

I think we should restrict the log in the production environment and move some unnecessary log.warn to log.debug for development needs.