I use a RichTextCtrl to show some chat messages.
If the program is running serval hours, it's going to use hundreds of MB
memory.
So I tried to limit the memory consume in the following way:
while self._rtc.GetNumberOfLines() >= 100:
len = self._rtc.GetLineLength(0)
self._rtc.Remove(0, len + 1)
But I failed. It doesn't work. It seems the memory doesn't be freed.
By the way, If I call self._rtc.Clear(), then the memory is freed.so I think
"Clear" method's implement is different from "Remove" method.
Is there another way to limit the memory use of RichTextCtrl?
Please help me. THANK YOU.
Though indirect, another approach would to have your own data object
which holds the chat lines and then clear the richtextctrl and
repopulate the window (which more or less happens behind the scenes
anyways). You can handle scrolling as well by keeping track of the
range you should be showing. On another front, did you try using the
Delete method?
···
On Aug 16, 1:02 am, zeb <zeb...@gmail.com> wrote:
I use a RichTextCtrl to show some chat messages.
If the program is running serval hours, it's going to use hundreds of MB
memory.
So I tried to limit the memory consume in the following way:
while self\.\_rtc\.GetNumberOfLines\(\) >= 100:
len = self\.\_rtc\.GetLineLength\(0\)
self\.\_rtc\.Remove\(0, len \+ 1\)
But I failed. It doesn't work. It seems the memory doesn't be freed.
By the way, If I call self._rtc.Clear(), then the memory is freed.so I think
"Clear" method's implement is different from "Remove" method.
Is there another way to limit the memory use of RichTextCtrl?
Please help me. THANK YOU.