Libraryless. Click here for Pure Java version (2977L/18K).
1 | set flag useNewPing. |
2 | |
3 | static <A> A memLimit(long allocationLimit, IF0<A> f) { |
4 | if (f == null) null; |
5 | long baseline = bytesAllocatedByCurrentThread(); |
6 | long limit = baseline+allocationLimit; |
7 | temp tempNewPing_addToStack(r { |
8 | if (bytesAllocatedByCurrentThread() > limit) |
9 | fail("Allocation limit for " + f + " exceeded: " + toM(allocationLimit) + " MB"); |
10 | }); |
11 | A a = f.get(); |
12 | ping(); |
13 | ret a; |
14 | } |
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: | 164 / 237 |
Version history: | 4 change(s) |
Referenced in: | [show references] |