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 7055501
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:45:23+00:00 2026-05-28T03:45:23+00:00

Since it is still not 100% clear when a LDM should be used I

  • 0

Since it is still not 100% clear when a LDM should be used I tried a simple memory test.
I created a DataView with a DataProvider that simply creates a list of few 100 entities with some big data inside (long String):

    private class HeavyDataProvider implements IDataProvider<HeavyBean> {

    @Override
    public void detach() {
    }

    @Override
    public Iterator<? extends HeavyBean> iterator(int first, int count) {
        List<HeavyBean> l = newArrayList();
        for (int i = 0; i < this.size(); i++) {
            l.add(new HeavyBean());
        }
        return l.iterator();
    }

    @Override
    public IModel<HeavyBean> model(HeavyBean heavyBean) {
        return new CompoundPropertyModel<HeavyBean>(heavyBean);
    }

    @Override
    public int size() {
        return 500;
    }
}

Using wicket’s DebugBar is see this creates a Page with a size of 5MB. In the javadoc of DataProvider it is stated that the model return in above model method is usually a detachable one so I changed this method to:

        @Override
    public IModel<HeavyBean> model(final HeavyBean heavyBean) {
        return new LoadableDetachableModel<HeavyBean>() {

            @Override
            protected HeavyBean load() {
                return heavyBean;
            }
        };
    }

Naively I was expecting the pagesize to be reduced in a big way now since the heavybeans will no longer be part of the model. Actual result: 5MB. Since the model will detach the heavyBean this must mean that something else still has a hold of it (DataView? Item?).

I saw other examples where DataView and DataProvider are combined in a similar fashion but for me it is unclear what the point is since it does not seem to make any difference regarding the pageSize/memory usage.

So, am I understanding/doing something wrong (likely) or are LDM’s useless in DataProviders?
Side question (sorry), in which scenario would you use an LDM?

  • 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-28T03:45:24+00:00Added an answer on May 28, 2026 at 3:45 am

    Your implementation of LDM is just plain wrong. It is holding a direct reference to the bean itself, and just returning it. This way, the bean will be serialized along the model, making it completely pointless.

    You should do something like this:

    @Override
    public IModel<HeavyBean> model(final HeavyBean heavyBean) {
        final Integer id = heavyBean.getId();
        return new LoadableDetachableModel<HeavyBean>() {
            @Override
            protected HeavyBean load() {
                return ServiceLocator.get(HeavyDao.class).get(id);
            }
        };
    }
    

    If you use the wicket-ioc module, the HeavyDao reference could be injected into the enclosing page/component.

    I think Wicket is really easy to use, but you must understand the basics of Java serialization, or else you may end up with a very bloated http session.

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

Sidebar

Related Questions

I know it is still not quite popular, since the spec was released just
Wikipedia: Directed Acyclic Graph Not sure if leaf node is still proper terminology since
I've been doing some researching and I'm still not 100% certain if this could
I stumbled on a piece of Ajax code that is not 100% safe since
Since Rails is not multithreaded (yet), it seems like a threaded web framework would
I have a program spawning and communicating with CPU heavy, unstable processes, not created
Maybe it is a bad habit which I still have since Flash Professional, but
Using C# .NET 3.5. It seems I'm not the only one, since a search
I'm not thinking too clearly right now and possibly overlooking something simple. I've been
Since I started studying object-oriented programming, I frequently read articles/blogs saying functions are better,

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.