• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Out of Memory Because Error Compressed Class Space

 
Ranch Hand
Posts: 58
1
  • Number of slices to send:
    Optional 'thank-you' note:
Hello All;

I am using Spring MVC version 5.3.29 with Hibernate version 5.6.15.Final, and I am getting Out of Memory Because Error Compressed Class Space although I set the size to be 3g using the argument -XX:CompressedClassSpaceSize=3g. In order to detect where is the memory leak happening and which class is keep loaded again and again, so I added the following argument for JVM: -Xlog:class+load=info  and we discovered that there are some classes which are hibernate model classes (classes defined to be mapped to the tables) are loaded and loaded again (based on the below obtained tomcat log). Please note that we are using session.createNativeQuery recently and some queries are still session.createSQLQuery.

In the hibernate model classes (that I created), I imported the following:



I am closing the sessions using session.flush(), session.clear(), session.close() and session.getSessionFactory().close().
Moreover, I am using the below hibernate dependency:



Please see the below results of the class-load logs which contains "__JVM_DefineClass__":



And ofcourse, the Compressed Class Space is keep increasing until I reach for out of memory.
Tomcat version is 9
JDK version is 17.
Operating System is Linux Ubuntu Server version 22.04.2 LTS

Appreciate the kindly help please.
Regards
Bilal
 
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
Please make sure that when you say "classes" you mean actual Classes and not instances of Classes (objects). You don't want to be compressing the wrong thing.

One thing that looks alarming to me, however, is that you're using javax.persistence classes to define your Entities but you talk about using a "session" as your persistence controller. javax.persistence  (now jakarta.persistence) defines the Java Persistence API. JPA does not use "sessions", it uses EntityManagers. The "session" is something that existed in legacy Hibernate, which is NOT JPA-compliant. I don't recommend writing anything for Hibernate's legacy ORM. It's obsolete and you should be using Hibernate JPA, instead.

In other words, I think that you are improperly mixing new and old Hibernate code and if so, it's not surprising that things don't work right.
 
Bilal Ghayad
Ranch Hand
Posts: 58
1
  • Number of slices to send:
    Optional 'thank-you' note:
Thank you for your help and kindly advise.

Please make sure that when you say "classes" you mean actual Classes and not instances of Classes (objects). You don't want to be compressing the wrong thing.



Actually I displayed what I see in the journal logs which is related to class-load, so based on that I said classes as it is displayed by class-load as shown in the below line (as sample of the logs):



Now coming to the sessions and EntityManagers, actually when creating session, I am using:
StandardServiceRegistry, SessionFactory and session and when I need to close it, then I use session.close() and session.getSessionFactory().close(). So I am in wrong direction? Can you please put me in the right track?

Moreover, can I know why the using of sessions is causing this class loader problem which cause the out of memory because Compressed Class Space is full?

Again, I am really very thankful for your great help and advise.
Regards
Bilal
 
Tim Holloway
Saloon Keeper
Posts: 27851
196
  • Number of slices to send:
    Optional 'thank-you' note:
Your log messages are meaningless to me. The message formatter isn't set up to supply all the information I need and in particular the actually logger name.

In JPA, you handle persistence by obtaining an EntityManager from an EntityManagerFactory. The EntityManager serves much the same purpose as the ancient Hibernate "Session", but the two are not compatible. You should not be referring to "session" at all in a JPA application and the fact that you could even compile without "session" being flagged as undefined means I suspect that you have mixed both types of Hibernate in the same application build.

This is roughly the same thing as expecting to operate an automatic-transmission vehicle using a manual clutch and gearshift. The parts don't match and as long as that isn't fixed, there's no telling what can go wrong.
 
reply
    Bookmark Topic Watch Topic
  • New Topic
vceplus-200-125    | boson-200-125    | training-cissp    | actualtests-cissp    | techexams-cissp    | gratisexams-300-075    | pearsonitcertification-210-260    | examsboost-210-260    | examsforall-210-260    | dumps4free-210-260    | reddit-210-260    | cisexams-352-001    | itexamfox-352-001    | passguaranteed-352-001    | passeasily-352-001    | freeccnastudyguide-200-120    | gocertify-200-120    | passcerty-200-120    | certifyguide-70-980    | dumpscollection-70-980    | examcollection-70-534    | cbtnuggets-210-065    | examfiles-400-051    | passitdump-400-051    | pearsonitcertification-70-462    | anderseide-70-347    | thomas-70-533    | research-1V0-605    | topix-102-400    | certdepot-EX200    | pearsonit-640-916    | itproguru-70-533    | reddit-100-105    | channel9-70-346    | anderseide-70-346    | theiia-IIA-CIA-PART3    | certificationHP-hp0-s41    | pearsonitcertification-640-916    | anderMicrosoft-70-534    | cathMicrosoft-70-462    | examcollection-cca-500    | techexams-gcih    | mslearn-70-346    | measureup-70-486    | pass4sure-hp0-s41    | iiba-640-916    | itsecurity-sscp    | cbtnuggets-300-320    | blogged-70-486    | pass4sure-IIA-CIA-PART1    | cbtnuggets-100-101    | developerhandbook-70-486    | lpicisco-101    | mylearn-1V0-605    | tomsitpro-cism    | gnosis-101    | channel9Mic-70-534    | ipass-IIA-CIA-PART1    | forcerts-70-417    | tests-sy0-401    | ipasstheciaexam-IIA-CIA-PART3    | mostcisco-300-135    | buildazure-70-533    | cloudera-cca-500    | pdf4cert-2v0-621    | f5cisco-101    | gocertify-1z0-062    | quora-640-916    | micrcosoft-70-480    | brain2pass-70-417    | examcompass-sy0-401    | global-EX200    | iassc-ICGB    | vceplus-300-115    | quizlet-810-403    | cbtnuggets-70-697    | educationOracle-1Z0-434    | channel9-70-534    | officialcerts-400-051    | examsboost-IIA-CIA-PART1    | networktut-300-135    | teststarter-300-206    | pluralsight-70-486    | coding-70-486    | freeccna-100-101    | digitaltut-300-101    | iiba-CBAP    | virtuallymikebrown-640-916    | isaca-cism    | whizlabs-pmp    | techexams-70-980    | ciscopress-300-115    | techtarget-cism    | pearsonitcertification-300-070    | testking-2v0-621    | isacaNew-cism    | simplilearn-pmi-rmp    | simplilearn-pmp    | educationOracle-1z0-809    | education-1z0-809    | teachertube-1Z0-434    | villanovau-CBAP    | quora-300-206    | certifyguide-300-208    | cbtnuggets-100-105    | flydumps-70-417    | gratisexams-1V0-605    | ituonline-1z0-062    | techexams-cas-002    | simplilearn-70-534    | pluralsight-70-697    | theiia-IIA-CIA-PART1    | itexamtips-400-051    | pearsonitcertification-EX200    | pluralsight-70-480    | learn-hp0-s42    | giac-gpen    | mindhub-102-400    | coursesmsu-CBAP    | examsforall-2v0-621    | developerhandbook-70-487    | root-EX200    | coderanch-1z0-809    | getfreedumps-1z0-062    | comptia-cas-002    | quora-1z0-809    | boson-300-135    | killtest-2v0-621    | learncia-IIA-CIA-PART3    | computer-gcih    | universitycloudera-cca-500    | itexamrun-70-410    | certificationHPv2-hp0-s41    | certskills-100-105    | skipitnow-70-417    | gocertify-sy0-401    | prep4sure-70-417    | simplilearn-cisa    |
http://www.pmsas.pr.gov.br/wp-content/    | http://www.pmsas.pr.gov.br/wp-content/    |