Is there a unit test way for memory leaks in JavaScript? I mean, is there a way to access the heap directly from javascript code to check individual DOM trees or increase memory usage?
I know that you can do this in Chrome Dev Tools, but I’m wondering if there is a way to do this directly from my unit tests, since it seems tedious to write some code, take a picture of the heap, perform potential memory of the ongoing operation, do another heap snapshot and repeat each operation of a potential memory leak every time you write another piece of code. Not to mention the fact that adding code in one place can cause an unexpected memory leak in another part of the application.
I just wrote an application with a huge memory leak, and I had to start from scratch. When I create the application this time, I want to make sure that my unit tests can detect that I just created a memory leak and that I can fix it as soon as possible.
I think I saw such tools for C ++, but not for Javascript. Somebody knows? Thanks!
source share