pytorch/aten/src/TH/THGeneral.cpp
/* Optional hook for integrating with a garbage-collected frontend.
 *
 * If torch is running with a garbage-collected frontend (e.g. Lua),
 * the GC isn't aware of TH-allocated memory so may not know when it
 * needs to run. These hooks trigger the GC to run in two cases:
 *
 * (1) When a memory allocation (malloc, realloc, ...) fails
 * (2) When the total TH-allocated memory hits a dynamically-adjusted
 *     soft maximum.
 */
Optional hook for integrating with a garbage-collected frontend.
If torch is running with a garbage-collected frontend ,
the GC isn't aware of TH-allocated memory so may not know when it
needs to run. These hooks trigger the GC to run in two cases.

(1) When a memory allocation (malloc, realloc, ...) fails
(2) When the total TH-allocated memory hits a dynamically-adjusted
soft maximum.
Optional hook for integrating with a garbage - collected frontend . If torch is running with a garbage - collected frontend the GC isn ' t aware of TH - allocated memory so may not know when it needs to run . These hooks trigger the GC to run in two cases . ( 1 ) When a memory allocation ( malloc realloc ... ) fails ( 2 ) When the total TH - allocated memory hits a dynamically - adjusted soft maximum .
void THSetGCHandler( void (*torchGCFunction_)(void *data), void *data )
{
  torchGCFunction = torchGCFunction_;
  torchGCData = data;
}
void THSetGCHandler ( void ( * torchGCFunction_ ) ( void * data ) , void * data ) { torchGCFunction = torchGCFunction_ ; torchGCData = data ; }
Optional hook for integrating with a garbage-collected frontend.
Optional hook for integrating with a garbage - collected frontend .