Hi,

How expensive is to "construct the pointers" ?
If it is not very expensive operation then I'd suggest you to do it in
Page#onConfigure() and to clean up in Page#onDetach().
Those two methods are called for each http request.

If it is expensive then the best I can think of is to store them in
"transient" fields so that they are null-ified when the Page is stored on
the disk.
Then in #onConfigure() you will have to make a check whether the pointers
are loaded or not.
The benefit here is that the last used page is kept as a live object in the
Http Session, so unless your user navigates to another page, or another
instance of this page, the pointers will be preloaded.

On Tue, Sep 25, 2018 at 12:43 PM yvus <yves.courvois...@enata.com> wrote:

> Dear All,
>
> I have the complex task to develop a webpage GUI for a java/c++ app, i.e.
> the java app contains objects that wrap c++ classes of a .so library. For
> example the Frame.java class wraps a corresponding c++ class frame.h (which
> does the math). Therefore we call in the constructor of the Frame.java
> class
> a c++ constructor through JNA and store the Pointer in a field.
>
> public class Frame {
>     private Pointer cppPointer;
>     public Frame() {
>         cppPointer = Wrapper.INSTANCE.frameConstructor(...)  // JNA call to
> c++ constructor retrieving the c++ pointer.
>     }
> }
>
> On the webpage, I have the following scenario in which we display a demo
> page which renders a 3d view. The user is able to displace an object which
> position is determined by the fields of Frame.java and hence the c++
> classes. Moving the object is done by changing 'values' in a form. Each of
> these 'values' directly modify the Frames and hence the Frame c++-class's
> attributes.
>
> In order to have the pointers created only once per page, we construct all
> the pointers in the constructor of the page and store them in a model which
> serializes the addresses. This allows to have the c++ side created only
> once
> on the page. This seems fine until we have to destroy the pointers memory.
>
> How to determine when we leave the page in order to destroy the Pointers?
> How would you manage this scenario? is it a good thing to construct the
> pointers in the constructors of the page? When would you allow to destroy
> the c++ allocated memory?
>
> Thanks
>
> --
> Sent from:
> http://apache-wicket.1842946.n4.nabble.com/Users-forum-f1842947.html
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to