@Kem T My understanding is that, technically, these are different things designed to achieve the same goal. Xojo uses reference counting where objects are destroyed as soon as there are no more references, but you'd prefer garbage collection where the unused objects are removed periodically during free time. (Someone's probably going to correct me here.)
Thanks Kem :) . Yes, I agree that these are two different methods to perform the same thing. Hmm.. Maybe I should break this into two different sub-questions.
Reference Counting: When Xojo automatically does reference counting to remove references, then this takes processor time away from electronics that communicate with timing. These delays interfere with the binary data received and sent to electronics. When Xojo performs reference removal of objects then this delay causes spaces in received and sent data with electronics. Since Xojo works on one core, then this core must perform all of the work. Delays in timing are causing issues. I am not sure if it is the reference counting algorithm, the large size of Xojo, or what the issue is, and this delay causes communication error due to timing delays. When I limit the use of reference objects being created or destroyed by only using global variables, then there is less reference counting that occurs. Since these electronic delays still occur, then I am guessing that local variables within Xojo are being used, objects created, and objects are being destroyed, which is causing delays in timing. Is there a way to prevent Xojo from reference counting to allow me to program electronics that require sensitive timing communication with electronics? Maybe this is clearer, or maybe not :)
Garbage collection: To my understanding (which could be completely incorrect), garbage collection in Xojo occurs to remove unused objects that have been dereferenced (see Reference counting above). Memory usage seems to increase for a while and then is flushed which lowers the size of the Xojo application in memory. Flushing takes processor time and causes delays in sending/receiving data in electronics. An example is that a binary 1 (on) is kept on for many milliseconds while garbage collection is performing object cleanups. Minimizing the use of local variables and attempting to only use global variables helps limit this issue in Xojo. Is there a way to prevent Xojo from Garbage Collecting unused variables, or at least allow me to delay this operation in the program so that I can complete my communication and then pause the program to allow Xojo to finish its garbage collection?
@Kem T You can implement your own garbage collection over reference counting, but how eat that might be will depend on the types of objects that are troubling you.
I have implemented my own garbage collection, and the issue that I am seeing is that Xojo is performing its own reference counting/garbage collection in the background that I have no control over. If I am able to control reference counting or garbage collection then I could program appropriate delays in the program. Right now the delays seem to be random. Is there a way to cause Xojo to perform reference counting or garbage collection at a specific time within the program.
@Kem T Or it might just be a matter of coding differently.
Coding differently by using only global variables does help alot, and not using local variables also minimizes timing issues. My guess (again I could be wrong) is that Xojo performs these operations in the background. I can control what I program, but unfortunately I am not able to change what happens in the Xojo program/background. This is where the issues seem to be coming from.
When I program in assembly, then I am not getting timing issues. I would prefer to use Xojo, and am curious to know if this is an option.
Thanks a bunch :)