Release memory made by small memory allocations
This can be tested with the following code:
for (int i = 0; i < 1000 * 1000; i++) {
doc->insertText(doc->documentEnd(), "abc\n");
}
doc->setModified(false);
doc->closeUrl();
Before the change memory usage is 1.6GiB, with the change it reduces to 210MiB.