• Welcome to Jose's Read Only Forum 2023.
 

Garbage collector in O2

Started by Chris Chancellor, December 05, 2018, 06:08:42 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Chris Chancellor

Hello Charles

how to get Garbage collector in O2 to run ?

in C# we can force the GC to run programmatically by issueing this command under certain conditions


System.GC.Collect()



Charles Pegge

The garbage collectors are not designed for explicit use. They operate whenever a string is assigned, after a string expression, at the end of a function and finally, at the end of the program.

Do you have an example where explicit garbage collection might be required?

Mike Lobanovsky

Hi Charles,

Does the O2 GC keep track of whether strings (and possibly, objects, UDTs and/or arrays too?) are actually used in a particular function or not before it fires its GC routines that might otherwise not be necessary at all?

Can you override garbage collection in a sequence of function calls that might form up the most time-critical portion of the application, and postpone it till much less demanding moments, e.g. user I/O and the like?

If not then you aren't in total control of your app's performance, speed and throughput wise.

That's what System.GC.Collect() is meant for in managed code.
Mike
(3.6GHz Intel Core i5 w/ 16GB RAM, 2 x GTX 650Ti w/ 2GB VRAM, Windows 7 Ultimate Sp1)

Charles Pegge

Hi Mike,

o2 avoids invoking unnecessary GC routines, but tends to 'collect' as soon as the strings go out of scope. You can't get it to hold back. However, there are many opportunities to optimise string management when timing is critical, like using raw bstrings instead of native o2 strings.

Chris Chancellor

Charles

the example code that i have is written in C# , it is an implementation of grid ( or Listview) and large string arrays
where GC needs to be invoked periodically during screen refreshing ( redrawing)

i'm just exploring ways to translate it to O2