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).

1  
static int regularGC_interval = 60000; // every minute
2  
static int regularGC_firstDelay = 20000; // clean up 20 seconds after loading VM
3  
static volatile java.util.Timer regularGC_timer;
4  
sO regularGC_condition; // F0<Bool> - set this to make GC depend on a condition
5  
6  
static int regularGC_countdown = -1;
7  
8  
static void regularGC() {
9  
  if (!_inCore()) ret with callJavaX('regularGC);
10  
  lock generalLock();
11  
  if (regularGC_timer == null)
12  
    regularGC_timer = doEvery_daemon(regularGC_interval, regularGC_firstDelay, r regularGC_doIt);
13  
}
14  
15  
static void regularGC_doIt() {
16  
  if (regularGC_countdown == 0) ret;
17  
  else if (regularGC_countdown > 0) --regularGC_countdown;
18  
  if (!isFalse(pcallF(regularGC_condition)))
19  
    timedGCPlusDeadlockSolving();
20  
  else
21  
    callOpt(javax(), 'cleanWeakMaps); // This is important, always do it
22  
}

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: 578 / 629
Version history: 16 change(s)
Referenced in: [show references]