We have two ways of Cache in Hibernate.
1) Memory (RAM)
2) Disk (HD)
Since you are trying to save the RAM, please try to create the cache in the disk.
Use the DiskStore option in the EnCache.
<cache>
<persistence strategy=”localRestartable|localTempSwap|none|distributed” synchronousWrites=”false|true”/>
</cache>
If you are using Java 7 and plus.
Go for BigMemory for the best performance.