Jose's Read Only Forum 2023

IT-Consultant: Charles Pegge => OxygenBasic => Topic started by: Chris Chancellor on December 05, 2018, 06:08:42 PM

Title: Garbage collector in O2
Post by: Chris Chancellor on December 05, 2018, 06:08:42 PM
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()


Title: Re: Garbage collector in O2
Post by: Charles Pegge on December 05, 2018, 06:44:28 PM
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?
Title: Re: Garbage collector in O2
Post by: Mike Lobanovsky on December 06, 2018, 12:09:40 AM
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.
Title: Re: Garbage collector in O2
Post by: Charles Pegge on December 06, 2018, 02:46:51 AM
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.
Title: Re: Garbage collector in O2
Post by: Chris Chancellor on December 06, 2018, 01:22:50 PM
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