Task Manager is not a very accurate way of measuring memory use. It can be an indicator of a memory leak, but it can be misleading.
In Windows, freeing memory (using free() in C or operator delete() in C++) does not shrink the size of your program in memory. The freed memory is not released back to the OS for use by other programs, instead it is freed to the local heap used by your program so that it can be reused within your program. So the typical behavior for a leak-free C++ program if you watch Task Manager is that it will grow to a certain size and then stay there. It doesn't shrink even if it frees all of the memory allocated from the heap.
However, if you program allocates and frees varying size chunks of memory repeatedly, the heap can become fragmented to the point that there is not enough contiguous free memory available for the next allocation, so the program has to ask for more heap from Windows. So even though there is no leak, the program continues to grow.
QML is implemented in C++ on top of Qt's C++ libraries, as far as I know, so the same rules should apply. If you are using pure QML in your program, then the memory leak is either within the QML implementation itself or in the way you are using it.
I think that what is likely happening with your program is that each time you swap windows, QML must ask for more memory because it is unable to find enough contiguous free memory to create the new window and all of its widgets. If you are loading the window from QML source each time you switch, then the QML engine must go through the loading, parsing, and byte code compilation each time you switch, and that probably consumes some memory. The QML engine doesn't "remember" that you are using the same two files over and over again; each one is a brand new file as far as it is concerned.
These kinds of problems are why I advised against doing this in my first answer to your thread.
Bookmarks