[Gambas-user] How to profile memory usage in gambas application ?

Olivier Cruilles olivier.cruilles at ...614...
Sat May 2 23:38:41 CEST 2015


Ok, I will investigate and I back to you.

Thank you

Cordialement,

Olivier Cruilles


> Le 2 mai 2015 à 17:11, Benoît Minisini <gambas at ...1...> a écrit :
> 
> Le 01/05/2015 20:05, Olivier Cruilles a écrit :
>> Hi Benoit, Is there a way to monitor usage of memory of objects
>> (Class, Collection, etc...) in Gambas please ? May be you have
>> already developed something like time execution profiler already
>> existing in Gambas but for memory usage ? My problem is I use an
>> Editor object in a project because it is so great to display text
>> with numbered lines and other possibilities that it offer but after
>> inserted 12000 lines just by Editor1.Text &= new_text_receive, the
>> memory usage of my program jump from 65 MB of memory resident to
>> around 1GB. So, with a memory profiler in Gambas it will easier to
>> find where I need to change my code to optimize space memory. Do you
>> think something can be made in this way please ? Thank you Olivier
>> 
> 
> Not automatically, but you can periodically print the number of each
> object of each class.
> 
> I don't see why the Editor would make the memory consumption jump suddenly.
> 
> But doing "Editor1.Text &= new_text" is very stupid, because it extracts
> the entire text from the Editor to a new string, creates another new
> string by concatenating "new_text", and the result is sent back to the
> Editor, and will be parsed so that each line is recreated. The heap
> becomes fragmented, and so the heap that is not used anymore cannot be
> actually freed.
> 
> Use the Insert() method instead. If it makes the memory consumption
> going down, you found the guilty code.
> 
> Regards,
> 
> -- 
> Benoît Minisini





More information about the User mailing list