3 ms·
That is true as a general trend, but in my experience with SWI-Prolog the effect is not linear, and frequent small collections do cost more (in MY applications)
by tom_mellior 11y ago
That is true as a general trend, but in my experience with SWI-Prolog the effect is not linear, and frequent small collections do cost more (in MY applications). For one thing, if you have long-lived data used throughout the program's whole lifetime, they will be visited on every collection without ever being freed. For another thing, if you have enough memory to fit all the data ever allocated by the program, you may not need to collect at all! Also, as mentioned in my previous comment, depending on the application there may be program parts where it is OK to trigger even a long-ish collection manually, while you want other parts to be fast and collection-free.
So, to reiterate: You are right in broad terms, but it all depends very much on the details of the application.