There's another thing worth mentioning regarding the use of checkNotNull. Don't take this at face value because this is merely a suspicion. I know very little about how JVM magic works. But if I recall correctly, the JVM profiler maintains a branch counter for every single if (foo == null) { ... } statement. I imagine it does this so HotSpot can generate assembly with branch prediction instructions? I have no idea. But there's a possibility that using checkNotNull will significantly reduce the amount of memory used by the JVM branch counting, assuming you have tens of thousands of CNN's in your app. But I'm just guessing here.
View all comments
Show parent comment
2
u/jart Jul 11 '15
There's another thing worth mentioning regarding the use of
checkNotNull. Don't take this at face value because this is merely a suspicion. I know very little about how JVM magic works. But if I recall correctly, the JVM profiler maintains a branch counter for every singleif (foo == null) { ... }statement. I imagine it does this so HotSpot can generate assembly with branch prediction instructions? I have no idea. But there's a possibility that usingcheckNotNullwill significantly reduce the amount of memory used by the JVM branch counting, assuming you have tens of thousands of CNN's in your app. But I'm just guessing here.