Question: Differences in hb_gcAll() and hb_gcCollectAll()

165 views
Skip to first unread message

hmpaquito

unread,
Jun 15, 2021, 11:38:26 AM6/15/21
to Harbour Users
As subject, please


Docs says:

hb_gcCollectAll()🔎⌃ | ☰ | Improve this doc
Scans all memory blocks and releases the garbage memory.
Syntax
void hb_gcCollectAll( void );
Arguments
None.
Returns
Nothing.
Description
This function scans the eval stack, the memvars table, the array of static variables and table of created classes for referenced memory blocks. After scanning all unused memory blocks and blocks that are not locked are released.


hb_gcAll()Source code🔎⌃ | ☰ | Improve this doc
Scans the memory and releases all garbage memory blocks.
Syntax
hb_gcAll()
Arguments
None
Description
This function releases all memory blocks that are considered as the garbage.

Antonio Linares

unread,
Jun 16, 2021, 2:09:18 AM6/16/21
to Harbour Users
Dear Paco,

hb_gcAll() is a high level (PRG) function that calls hb_gcCollecAll() from low level (C):

/* Check all memory blocks if they can be released
 */
HB_FUNC( HB_GCALL )
{
   HB_STACK_TLS_PRELOAD

   /* call hb_ret() to clear stack return item, HVM does not clean
    * it before calling functions/procedures if caller does not
    * try to retrieve returned value. It's safe and cost nearly
    * nothing in whole GC scan process. It may help when previously
    * called function returned complex item with cross references.
    * It's quite common situation that people executes hb_gcAll()
    * immediately after such function. [druzus]
    */
   hb_ret();

   hb_gcCollectAll( hb_parldef( 1, HB_TRUE ) );
}

best regards

hmpaquito

unread,
Jun 17, 2021, 3:01:50 AM6/17/21
to Harbour Users
Dear Antonio,

Thank you very much

Reply all
Reply to author
Forward
0 new messages