Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

22
LINES

< > BotCompany Repo | #1006295 // regularGC - perform GC regularly (once a minute) - now installed automatically by VM

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (6436L/36K).

static int regularGC_interval = 60000; // every minute
static int regularGC_firstDelay = 20000; // clean up 20 seconds after loading VM
static volatile java.util.Timer regularGC_timer;
sO regularGC_condition; // F0<Bool> - set this to make GC depend on a condition

static int regularGC_countdown = -1;

static void regularGC() {
  if (!_inCore()) ret with callJavaX('regularGC);
  lock generalLock();
  if (regularGC_timer == null)
    regularGC_timer = doEvery_daemon(regularGC_interval, regularGC_firstDelay, r regularGC_doIt);
}

static void regularGC_doIt() {
  if (regularGC_countdown == 0) ret;
  else if (regularGC_countdown > 0) --regularGC_countdown;
  if (!isFalse(pcallF(regularGC_condition)))
    timedGCPlusDeadlockSolving();
  else
    callOpt(javax(), 'cleanWeakMaps); // This is important, always do it
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, sawdedvomwva, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1006295
Snippet name: regularGC - perform GC regularly (once a minute) - now installed automatically by VM
Eternal ID of this version: #1006295/17
Text MD5: a5eaa794cd98d39767f01c7601a3f135
Transpilation MD5: 110750ebe633ede3f53dabe312514fb4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-04 20:36:49
Source code size: 842 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 573 / 619
Version history: 16 change(s)
Referenced in: [show references]