I’ve been reading about tuning wicket session size and I’ve found that is recommended to use LoadableDetachableModel to dont make the models live forever. Are Property models(Property and PropertyCompoundModel) so expensive?
When to use LDM or Property Models?
It always depends on what you’re trying to achieve. So it’s important to understand what the cost is.
Between requests, Wicket normally serialises your page object and everything it references. This includes all the components on the page and consequently all their models. The only time this doesn’t happen is when a page is stateless.
Most model implementations contain a non-transient reference to the underlying model object, so if your model contains a reference to a large object and the page isn’t stateless, it causes an overhead in serialisation times and more importantly, the memory footprint of the session.
LoadableDetachableModelworks differently, it only contains a transient reference to the underlying model object, therefore when it’s serialised, the model object isn’t. The downside of this is that you have to reconstruct the model object for each request.So your question is really this: does the cost of using traditional models outweigh the cost of
LoadableDetachableModel? As has already been mentioned, if your model object comes from a database, it is almost always worth using LDMs.Another thing you must remember (and a strong argument in LDMs favour) is that models can be chained. So you can still use a
CompoundPropertyModelthat is backed by a LDM.