3 ms·
Is Java escape analysis done at compile time or run time? I don't know. FYI: As I understand, escape analysis is frequently used to either (a) avoid allocatin
by throwaway2037 5y ago
Is Java escape analysis done at compile time or run time? I don't know.
FYI: As I understand, escape analysis is frequently used to either (a) avoid allocating on the heap, or (b) auto-magically free-ing a malloc'd object from a tight scope.
- pjmlp 5y agoFirst of all it depends on the implementation, the language specification doesn't state how it works. https://en.m.wikipedia.org/wiki/List_of_Java_virtual_machines https://en.m.wikipedia.org/wiki/List_of_Java_virtual_machine... As it stands is mostly done at runtime and only for a). Otherwise you are better with try-resources, and for something like malloced memory there are off-GC heap APIs. Also Valhalla will eventually land, although it is getting long by now.
- vips7L 5y agoPersonally I wish they would move some escape analysis to compile time just to help with memory consumption. I’m assuming it would require byte code changes though.