PtClearWidget

I’m loading various picture modules onto PtPane on base window. When I use
PtClearWidget to destroy all children of the pane (which now are widgets
from my module and the module itself(??)), it does not seem to release the
memory, because app. memory keeps growing and growing with each new module
re-loaded. By cca 20k each ApCreateModule call. It gets to the point the
Photon just stops redrawing anything that does not have immediate focus.

The sequence is: … ApCreateModule, PtReRealizeWidget, PtClearWidget,
ApCreateModule, PtReRealizeWidget, etc … These modules contain
OSContainer with PtTrend and PtGrid in it. One or more.

The doc. for PtClearWidget state the call will destory all “nonprocreated”
chidren - what does it exactly mean “nonprocreated”?

Thanks for your input.

Joe

Joe Hezina <hezinjo@snapon.com> wrote:

I’m loading various picture modules onto PtPane on base window. When I use
PtClearWidget to destroy all children of the pane (which now are widgets
from my module and the module itself(??)), it does not seem to release the
memory, because app. memory keeps growing and growing with each new module
re-loaded. By cca 20k each ApCreateModule call. It gets to the point the
Photon just stops redrawing anything that does not have immediate focus.

You’re creating a two things each time you do the
ApCreateModule() call with picture modules:
a) an in-memory template which describes the widgets in the
module
b) copies of the widgets themselves, which get parented in the
container you use in the ApCreateModule() parent
parameter

The PtClearWidget() is causing the copies of the widgets to be
destroyed, but the template is still there.

I think the solution to your problem is not to use
ApCreateModule() for repeated creations. Open the picture module
as a database, and then grab the widgets you need from it as
individuals or as a family. If you make everbody else in the
module the child of a PtGroup, you can just grab them all using
ApCreateWidgetFamily() against the PtGroup.


The doc. for PtClearWidget state the call will destory all “nonprocreated”
chidren - what does it exactly mean “nonprocreated”?

Procreated children are the component widgets of a compound
widgets. For instance, PtMultiText is really a
PtMultiTextContainer that contains the PtMultiText and
(optionally, depending on what text is involved and the
dimensions of the widget) one or two PtScrollbars and a PtBasic.

Most compound widgets don’t allow you to drop other widgets into
them, either in PhAB or from code. You can’t put PtButtons
inside a PtMultiText or PtComboBox, for instance.

Things get complicated when you get a PtScrollContainer, which
can have not only procreated children (the slidebars and basic),
but also things like PtButtons, etc. These latter are
“nonprocreated” children. So, when you do a PtClearWidget(), you
want the PtScrollContainer to get rid of the PtButton, etc., but
leave the scrollbars. Clearer?


Norbert Black
QSSL Training Services

Absolutely Norbert, thanks a lot.
That’s the part when I was sleeping in the class, I think… :slight_smile:

Norbert Black <nblack@qnx.com> wrote in message
news:9c780u$5d2$1@nntp.qnx.com

Joe Hezina <> hezinjo@snapon.com> > wrote:
I’m loading various picture modules onto PtPane on base window. When I
use
PtClearWidget to destroy all children of the pane (which now are widgets
from my module and the module itself(??)), it does not seem to release
the
memory, because app. memory keeps growing and growing with each new
module
re-loaded. By cca 20k each ApCreateModule call. It gets to the point the
Photon just stops redrawing anything that does not have immediate focus.

You’re creating a two things each time you do the
ApCreateModule() call with picture modules:
a) an in-memory template which describes the widgets in the
module
b) copies of the widgets themselves, which get parented in the
container you use in the ApCreateModule() parent
parameter

The PtClearWidget() is causing the copies of the widgets to be
destroyed, but the template is still there.

I think the solution to your problem is not to use
ApCreateModule() for repeated creations. Open the picture module
as a database, and then grab the widgets you need from it as
individuals or as a family. If you make everbody else in the
module the child of a PtGroup, you can just grab them all using
ApCreateWidgetFamily() against the PtGroup.


The doc. for PtClearWidget state the call will destory all
“nonprocreated”
chidren - what does it exactly mean “nonprocreated”?

Procreated children are the component widgets of a compound
widgets. For instance, PtMultiText is really a
PtMultiTextContainer that contains the PtMultiText and
(optionally, depending on what text is involved and the
dimensions of the widget) one or two PtScrollbars and a PtBasic.

Most compound widgets don’t allow you to drop other widgets into
them, either in PhAB or from code. You can’t put PtButtons
inside a PtMultiText or PtComboBox, for instance.

Things get complicated when you get a PtScrollContainer, which
can have not only procreated children (the slidebars and basic),
but also things like PtButtons, etc. These latter are
“nonprocreated” children. So, when you do a PtClearWidget(), you
want the PtScrollContainer to get rid of the PtButton, etc., but
leave the scrollbars. Clearer?


Norbert Black
QSSL Training Services

Joe Hezina <hezinjo@snapon.com> wrote:

Norbert Black <> nblack@qnx.com> > wrote in message
news:9c780u$5d2$> 1@nntp.qnx.com> …
Joe Hezina <> hezinjo@snapon.com> > wrote:
I’m loading various picture modules onto PtPane on base
window. When I use PtClearWidget to destroy all children of
the pane (which now are widgets from my module and the
module itself(??)), it does not seem to release the
memory, because app. memory keeps growing and growing with
each new module re-loaded. By cca 20k each ApCreateModule
call. It gets to the point the Photon just stops redrawing
anything that does not have immediate focus.

Just a follow-up question, Joe - are you doing this
create/clear/create/clear/… sequence in a tight loop? I’d
expect you to get the results you saw if you were, but not
otherwise.

When widgets are destroyed, things happen in a two stage sequence:

  1. When you call PtDestroyWidget() (which PtClearWidget() does
    under the covers against the non-procreated children of the
    container widget you pass as parameter):
  • the target widget (and any children) are unrealized
  • these widgets have the Pt_DESTROYED bit set in the
    Pt_ARG_FLAGS resource
  1. When your process returns to the event processing loop
    (with a “return( Pt_CONTINUE );”), or calls
    PtSynchPhoton(), the relevant widgets have their memory
    freed.

So, let us know which you were doing, OK? There may be something
else going on in your code that’s causing this, if you’re not
tight looping.

The doc. for PtClearWidget state the call will destory all
“nonprocreated” chidren - what does it exactly mean
“nonprocreated”?

Procreated children are the component widgets of a compound
widgets. [snip further details] Clearer?

Absolutely Norbert, thanks a lot.
That’s the part when I was sleeping in the class, I think… > :slight_smile:

Ah, the truth comes out! :slight_smile:

Take care,


Norbert Black
QSSL Training Services