CrocodileShoes (2) [Avatar] Offline

Here's my situation.

I have the following components and models:

A service object that retrieves a list of objects from storage and stores the results in a member. This is held by my Panel.

A LoadableDetachableModel that returns the list of objects from the service object. That is,
protected Object load() {
return queryService.getResults();

A listview that is passed the model object above. I do this so I can display various member fields of the objects in the list (presently it's just using the title and url fields). For example:

protected void populateItem(ListItem item) {
Document Doc = (Document) item.getModelObject();
Map<String, Object> values = Doc.getFieldValueMap();
Iterator<String> it = values.keySet().iterator();
String title = "Document Title";
while (it.hasNext()) {
String fieldKey =;
if(fieldKey.equals("title")) {
title = (String) values.get(fieldKey);
if(fieldKey.equals("url")) {
String url = (String) values.get(fieldKey);
item.add(new ExternalLink("title", url , title));

I can't help but feel I've done something wrong though. If the service returns a list of objects (documents) that is larger than say 20 i get outofmemory exceptions.

I've definitely not grasped some of Wickets model concepts!
Eelco12 (100) [Avatar] Offline
Re: Listing a set of results. Am I doing it correctly?
Looks fine to me, not sure what's wrong. You should try using a profiler (YourKit for instance) to find out where memory is retained and what the causes you to run out of memory.

Good luck.
CrocodileShoes (2) [Avatar] Offline
Re: Listing a set of results. Am I doing it correctly?
Thanks, Eelco.

Somebody recommended SAP heap analyzer on the ##wicket irc channel so I used that yesterday to try and figure out what was going wrong.

It turns out that one of the fields in the objects the queryService returns (Documents) is the document itself! So there are megabytes of char[]'s stored in the hash map! In other words the list that queryService.getResults() returns is massive. I guess i'll have to figure our how to store this "outside" of wicket and just load the fields such as title etc into the Gui.

From what I've read so far I think I need to utilise Dataproviders and/or dataview.

Furthermore, as you can see above I've used LoadableDetachable model without understanding it properly but i'm sure it must play a part.