Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3604452
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T20:59:57+00:00 2026-05-18T20:59:57+00:00

I’m running into the following (common) error after I added a new DB table,

  • 0

I’m running into the following (common) error after I added a new DB table, hibernate class, and other classes to access the hibernate class:

java.lang.OutOfMemoryError: Java heap space

Here’s the relevant code:

From .jsp:

<% 
com.companyconnector.model.HomepageBean homepage = new com.companyconnector.model.HomepageBean();
%>

From HomepageBean:

public class HomepageBean {

        ...

    private ReviewBean review1;
    private ReviewBean review2;
    private ReviewBean review3;



    public HomepageBean () {

        ...

        GetSurveyResults gsr = new GetSurveyResults();
        List<ReviewBean> rbs = gsr.getRecentReviews();  
        review1 = rbs.get(0);  
        review2 = rbs.get(1);
        review3 = rbs.get(2);
}

From GetSurveyResults:

public List<ReviewBean> getRecentReviews() {

    List<OpenResponse> ors = DatabaseBean.getRecentReviews();
    List<ReviewBean> rbs = new ArrayList<ReviewBean>();


    for(int x = 0; ors.size() > x; x =+ 2) {

     String employer = "";
     rbs.add(new ReviewBean(ors.get(x).getUid(), employer, ors.get(x).getResponse(), ors.get(x+1).getResponse()));

    }

    return rbs;

}

and lastly, from DatabaseBean:

public static List<OpenResponse> getRecentReviews() {

  SessionFactory session = HibernateUtil.getSessionFactory();
  Session sess = session.openSession();
  Transaction tx = sess.beginTransaction();

  List results = sess.createQuery( 
    "from OpenResponse where (uid = 46) or (uid = 50) or (uid = 51)"
  ).list();

  tx.commit();
  sess.flush();
  sess.close();
  return results;

}

Sorry for all the code and such a long message, but I’m getting over a million instances of ReviewBean (I used jProfiler to find this). Am I doing something wrong in the for loop in GetSurveyResults? Any other problems?

I’m happy to provide more code if necessary.

Thanks for the help.

Joe

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T20:59:58+00:00Added an answer on May 18, 2026 at 8:59 pm

    Using JProfiler to find which objects occupy the memory is a good first step. Now that you know that needlessly many instances are created, a logical next analysis step is to run your application in debug mode, and step through the code that allocates the ReviewBeans. If you do that, the bug should be obvious. (I am pretty sure I spotted it, but I’d rather teach you how to find such bugs on your own. It’s a skill that is indispensable for any good programmer).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently running into a problem where an element is coming back from
I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.