Thank you for your help.
It turned out to be a a really interesting problem.
We had a detached entity called Locality.
As part of the transactions we were doing something like:
It turns out to be that whenever we invoked this method, theDetachedLocality entity keep a reference to the xxxEntity in its ChangeTracking attributes (added to locality via change weaving), therefore all our xxxEntity objects (1 Million) stayed in memory.
The funny thing is that xxxEntity.locality was a uni directional @ManyToOne so i had never thought that by doing xxxEntity.setLocality(theDetachedLocality) any of the ChangeTracking attributes of theDetachedLocality would ever keep track of changes on the xxxEntity but it dead
we found it analyzing a heap dump
Just out of interest, do you know why EL does this?
Thanks again for your help.