I have a caching app in Java and I need to put objects of different size in cache. The problem is that I didn't really know how to count the size of a custom object and I've found the solution - to use the library: http://mvnrepository.com/artifact/com.googlecode.sizeofag/sizeofag/1.0.0. To run the program using the library I need to specify command-line argument -javaagent. So, how can I do it if I'm using maven???
The program is simple:
protected static Boolean b;
public static void main( String[] args )
{
System.out.println(SizeOfAgent.sizeOf(b));
}
This is the output:
0
Can not access instrumentation environment.
Please check if jar file containing SizeOfAgent class is
specified in the java's "-javaagent" command line argument.
P.S. I know, that such kind of question already exists, but it has no proper answer.