Question: Say we have the following classes:

```
class DoubleOhSeven {
  public static void doSomethingClassy();
  public static void neverDoThisClassy();
}

class Dude {
  public void doSomething();
  public void neverDoThis();
}

public class Party {
  public static void main(String[] args){
    DoubleOhSeven.doSomething();
    Dude guy = new Dude;
    guy.doSomething();
  }
}

```

Of course, all the methods will be compiled into their respective `.class`: do the unused static/instance methods occupy memory at run time? What about unused inherited or imported methods?

Answer: 
Since classes are safed in ther PermGen for Sun Hotspot JVMs (that will change for Java 8), you can do something like this, first run:

```

MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
long before = memoryMXBean.getNonHeapMemoryUsage().getUsed();
new Dude(); // class must not be loaded before
System.out.println("Usage of dude is " + (memoryMXBean.getNonHeapMemoryUsage().getUsed() - before) + " bytes");

```

And you will see something like this: 
*Usage of dude is 6432 bytes*

And then create a Dude class without the unused method and run the test:

```

MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
long before = memoryMXBean.getNonHeapMemoryUsage().getUsed();
new DudeWithoutNeverDoThis(); // must not be loaded before
System.out.println("Usage of dude without 'nerverDoThis' is " + (memoryMXBean.getNonHeapMemoryUsage().getUsed() - before) + " bytes");

```

and you see the difference (*Usage of dude without 'nerverDoThis' is 6176 bytes*)
The unused methods inrease the class size, but classes are stored in a so called PermGen memory. The heap memory, where regular java objects are stored, is not affected by class size