How do I know why js memory cannot be reclaimed?

there are many places in the program that need to use closures, and I didn"t pay much attention to memory at the beginning of writing. Now that the program is finished, it is found that if the memory keeps increasing after running repeatedly, some things are not recovered by cg. The details are as follows

memory usage in running programs
clipboard.png

clipboard.png

you can see that only the part is recycled, but the part is still in memory (for example, Component has been * 1000).
because now that the program has been written and there is so much code, it is really difficult to find references in the code that cannot be recycled. Do you have any good methods or tools?


for example, writing a large framework like vue or react may cause memory leaks at the slightest inadvertence. Do you wonder what tools people like you will use when developing? is it all based on experience + Google devtools?


when writing code, you should note that objects with a large amount of data should not be referenced by multiple variables, and then set to null. If there is an object with a large amount of data that needs to be used many times, especially in a single page application, put the object under a custom attribute of window to facilitate management.
in the past, when gis was used in vue-based single-page applications, jquery had to be used. Due to historical problems, some objects with a large amount of data in gis encapsulation were referenced by multiple variables, so that the memory could not be freed by setting it to null. Finally, the problem was solved by keep-alive (loading only once) and iframe+PostMessage (automatically releasing memory when refreshed).

Menu