IdeaJol
IdeaJol copied to clipboard
Inspections
The plugin can provide some inspections but I'm not sure which one. I have the only one idea: to inspect object which layout is bigger than a cache line i.e. 64 bytes. But here occurs a problem with configuration:
- Which layout should be used? This should be configurable somehow.
- Should we inspect all classes or a simplest DTO's? For example it's ok to have a big object for a Controller class because anyway it's a singleton.
- Should we inspect platform and dependencies classes or only app code? It's a good thing to notify a user that it uses a class from library which have a big footprint.
I should ask in JOL dev list which inspections are possible.
Also another problem here is that the inspection can be time consuming because of converting PSI tree to ClassData #10. Maybe to make a quick calculation we can make it ourself.
First version was implemented and sent to be published. Inspection called "Java | Memory | Class have too big memory footprint" and shows a warning "Class have too big memory footprint". I tried on my working project and results are quite interesting. ATM we have few problems:
- Threshold is set to 64 (cache line) and this cause a lot of files to be reported. Maybe we have to change the default threshold.
- The whole class is getting marked with warning making the code unpleasant. Hotfix working only if set cursor on class name. I have to consult with JB plugin devs about how to do it better.
- Analyze is time consuming but it turned out not so slow as I expected. #10 should help a little bit. Also in fact we don't have to calculate full size, we need just to know that is bigger than threshold and skip other fields.
- A lot of DTOs are really HUGE: more than 3 cache lines it's quite ok here. I need to add an option to disable DTOs checking (by suffix DTO or Jackson annotation).
- Needs to be added to business login suffixes
Handler
,Factory
,Provider
,Utils
,Registry
,Filter
,Interceptor
,Executor
,Test
,Spec
. The checking should be allowed by an option. - It's better to show the size of object directly in message: "Class have too big memory footprint: 232" but this may consume more memory in IntelliJ.
- Tests are analyzed too which is not so useful.
- Most container and entity classes i.e. not DTOs but those who have
hashCode()
method are quite small. This is a good news.