I observe unusual behavior, and I would like to understand what is happening.
Imagine a simple setup.
First, I have a bezelless bean that just returns something:
@Stateless public class SimpleService{ private Map<String, String> map; @PostConstruct public init(){ map = new HashMap<>(); } public Map<String,String> getMap(){ return map; } }
Then I have another stateless bean that does some processing
@Stateless public class ProcessService{ private static final Logger log = LoggerFactory.getLogger(ProcessService.class); private static final int MAX = 2000; @Inject private SimpleService simpleService; @TransactionAttribute(TransactionAttributeType.REQUIRED) public void process(){ final long start = System.currentTimeMillis(); for(int i=0; i<MAX; i++){ simpleService.getMap(); } final long end = System.currentTimeMillis(); log.info(MessageFormat.format("Process took {0} ms", end - start)); } }
Then I have a simple CDI bean to call the process method.
Result:
When I call the process method several times in a row, the process time increases:
Process took 900 ms Process took 1,100 ms Process took 1,200 ms Process took 1,400 ms
And it continues to grow every time the method is called.
How can this be explained?
I am using Java JDK 1.7.0_25 and JBOSS EAP 6.1.
EDIT
By the way, the only way to "reset" is the processing time for this method - to restart the server.
phoenix7360
source share