Refreshing page with multiple StreamResources causes steady increase of pool size
In a project that has a running database connection, when multiple images are loaded onto a page via StreamResources, every time the page refreshes, new connections are opened and old ones are not closed. This leads to the pool size getting maxed out, until no more connections can be opened, causing problems in the application.
The more images are loaded via StreamResources, the more connections are opened. This needs to be done in quick succession, if the StreamResource calls are slowly debugged, the connections are properly managed and the problem does not occur.
Steps to Reproduce:
Open attached project
Fix PIC_PATH inside MainLayout.java (folder is included in the project's root directory)
Run on server
Press F5 ~5 times
Now I can refresh the page as many times as I want without problems.
after upgrading the project to 1.04 i get the same issue like
and can’t test it.
Fixed this issue by adding lazy initialization for the EntityManager to the per-request session strategy. This means that the EntityManager is only created on demand, and not on every request made to the server application. This should increase performance over all for the framework.