Differences
This shows you the differences between two versions of the page.
| |
| cfnet:cfheader:real_time:index [2026/02/16 06:13] – created - external edit 127.0.0.1 | cfnet:cfheader:real_time:index [2026/02/16 06:17] (current) – [Avoid Heap Memory Allocations in the Sync() Thread] admin |
|---|
| |
| .NET does not provide a way to permanently disable the garbage collection, but there is a simple way to avoid it: Don't allocate memory on the heap. The [[https://api.comfiletech.com/csharp/api/ComfileTech.Cfnet.Cfheader.Cfheader.Sync.html#ComfileTech_Cfnet_Cfheader_Cfheader_Sync|Cfheader.Sync()]] method has already been carefully optimized to avoid any heap allocations, but to maintain that optimization, the thread that calls [[https://api.comfiletech.com/csharp/api/ComfileTech.Cfnet.Cfheader.Cfheader.Sync.html#ComfileTech_Cfnet_Cfheader_Cfheader_Sync|Sync()]], and any event handlers tied to it, must also not allocate memory on the heap. If heap allocations are carefully avoided and eliminated, the garbage collector will not run, and the timing of the main loop calling [[https://api.comfiletech.com/csharp/api/ComfileTech.Cfnet.Cfheader.Cfheader.Sync.html#ComfileTech_Cfnet_Cfheader_Cfheader_Sync|Sync()]] will be significantly improved. | .NET does not provide a way to permanently disable the garbage collection, but there is a simple way to avoid it: Don't allocate memory on the heap. The [[https://api.comfiletech.com/csharp/api/ComfileTech.Cfnet.Cfheader.Cfheader.Sync.html#ComfileTech_Cfnet_Cfheader_Cfheader_Sync|Cfheader.Sync()]] method has already been carefully optimized to avoid any heap allocations, but to maintain that optimization, the thread that calls [[https://api.comfiletech.com/csharp/api/ComfileTech.Cfnet.Cfheader.Cfheader.Sync.html#ComfileTech_Cfnet_Cfheader_Cfheader_Sync|Sync()]], and any event handlers tied to it, must also not allocate memory on the heap. If heap allocations are carefully avoided and eliminated, the garbage collector will not run, and the timing of the main loop calling [[https://api.comfiletech.com/csharp/api/ComfileTech.Cfnet.Cfheader.Cfheader.Sync.html#ComfileTech_Cfnet_Cfheader_Cfheader_Sync|Sync()]] will be significantly improved. |
| | |
| | [[..:index|CFHEADER - USB Interface to CFNET IO Modules]] |
| |
| |