Libraryless. Click here for Pure Java version (2977L/18K).
set flag useNewPing. static <A> A memLimit(long allocationLimit, IF0<A> f) { if (f == null) null; long baseline = bytesAllocatedByCurrentThread(); long limit = baseline+allocationLimit; temp tempNewPing_addToStack(r { if (bytesAllocatedByCurrentThread() > limit) fail("Allocation limit for " + f + " exceeded: " + toM(allocationLimit) + " MB"); }); A a = f.get(); ping(); ret a; }
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
| Snippet ID: | #1031537 | 
| Snippet name: | memLimit | 
| Eternal ID of this version: | #1031537/5 | 
| Text MD5: | c96acc07475b9c1fd694738a99ed2dd6 | 
| Transpilation MD5: | ec51b3abc13452138afe93ddd1ce8840 | 
| Author: | stefan | 
| Category: | javax / sandboxing | 
| Type: | JavaX fragment (include) | 
| Public (visible to everyone): | Yes | 
| Archived (hidden from active list): | No | 
| Created/modified: | 2021-06-20 05:04:35 | 
| Source code size: | 421 bytes / 14 lines | 
| Pitched / IR pitched: | No / No | 
| Views / Downloads: | 372 / 491 | 
| Version history: | 4 change(s) | 
| Referenced in: | [show references] |