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

  • SEARCH
  • Home
  • 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 7973949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:14:38+00:00 2026-06-04T08:14:38+00:00

I have an Java EE application as follows: – Server is on Amazon (large

  • 0

I have an Java EE application as follows:
– Server is on Amazon (large instance, 2 CPU @ 2.27GHz, 8GB RAM)
– Static content served directly by Apache
– JSF2 (Mojarra 2.1.3) and JPA 2 (Eclipselink 2.3.0) running on Glassfish 3.1.1
– Facelets/XHTML get content from ViewScoped managed beans, that connect to @Local Stateless EJB that do all the processing, including getting data from other @Local Stateless EJB that use JPA
So typically:

XHTML --> ViewScoped Managed Bean --> Service EJB --> Data EJB --> JPA

I know I could/should remove the 2 layers of EJB to one or even none, given I run only one instance of Glassfish but for now I don’t think this is the issue.

The performance of the application is ok (2.2MB including images in < 5s). The problem is that when we have > 90 users online the system becomes really slow ( > 30 s per page, even if most of it is cached).
At that time the CPU was 50% used and RAM was 100% used.

So I ran JProfiler and I am not sure how to deal with one type of result.
In the homepage, we have a list of categories, and a number of product is associated to each category (a shopping website that tells how many product in each category). The code to get the list of Category is:

ViewScoped Bean

public List<Category> getLiveCategoriesInfo() {
    if (liveCategories == null) {
        liveCategories = liveCategoryService.getLiveCategories(getLocale().getLang().getLanguageId());
    }
    return liveCategories;
}

getLocale() is retrieved from a SessionScoped Bean injected using ManagedProperty

Service EJB:

public List<Category> getLiveCategories(final Integer langId) {
  List<LiveCategory> lives = categoryBean.getLiveCategories(langId);
  // ... some processing involving looping through the list above
  return livesCategories;
}

Data EJB:

public List<LiveCategory> getLiveCategories(final Integer langId) {
  List<LiveCategory> categories = new ArrayList<LiveCategory>();
  Query cq = getEntityManager().createNamedQuery(Category.FIND_LIVE);
  try {
    categories = cq.getResultList();
  } catch (NullPointerException npe) {
     // ...
  }
  return categories;
}

JProfiler Memory View shows that at every request on the homepage (even for the same user) a new batch of Category is added to the memory (43 to be precise, which is the number of categories displayed). The Category is not managed by JPA (the list from JPA is used to create POJO ‘manually’).
How can I release these entities from the memory. I would expect them to be GC when the view is gone. But the ViewScoped bean is itself is not GC’d, there is a bunch of instances that stay in memory.

What should I look for to release these objects?
– Is using a @ManagedProperty in a ViewScoped bean to get an instance of SessionScoped bean preventing the ViewScoped one to be GC’d?
– Is there some other mistake I should look for?

I did check the other threads about JSF Best practices and Performance guidelines but it doesn’t help.

  • 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-06-04T08:14:40+00:00Added an answer on June 4, 2026 at 8:14 am

    I think your problem is related to how you are using view scope and session scope. In few words, you are filling the memory with objects that does not change over the lifetime of the page. Instead, you should use a request scope bean to cache those results only while the request is processed, and use @ManagedProperty annotation or whatever(create value expression or call Application.evaluateExpressionGet to get the parameters from your view scope or session scope beans. In that way, the reference to the entities will be released when the request ends, and they will be collected by the GC.

    If you are really interested in the performance part, check this blog:

    Understanding JSF 2 and Wicket: Performance Comparison

    The test code is already tuned for get the best performance for JSF and Wicket. It is quite simple to tune JSF, so you usually should watch your ORM tool for performance tips.

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

Sidebar

Related Questions

We have a java application which run as server running on a remote windows
I have a Java application that makes heavy use of a large file, to
I have a database server communicating with a Java application server using JDBC. I
I have a Java Applet application. The use case is as follows: The users
I have a Java application runnning on a Glassfish server using JSF 2.0.2. at
I have Java application which sends pointer to function (callback) to some native dll
I have a java-application using JDBC for database interaction. I want to do a
I have an Java application running in JBoss in which I have enabled JMX
I have a Java application which requires certain software (one of them being Perl)
I have a Java Application which has to load an DLL with a few

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.