QNX RTOS v4 Knowledge Base
QNX RTOS v4 Knowledge Base
Title |
PxLoadImage() memory management |
Ref. No. |
QNX.000009771 |
Category(ies) |
Development |
Issue |
How will PtLabel handle de-allocation of an image?
After we created a PtLabel, we loaded image #1 with PxLoadImage().Then we set the Pt_ARG_LABEL_DATA resource of the PtLabel with image #1. Load another image (#2) with PxLoadImage(), set the Pt_ARG_LABEL_DATA resource of the PtLabel with image #2. Will PtLabel released the memory for image #1?
|
Solution |
No, if you do not explicitly set the appropriate image release flags prior to setting the Pt_ARG_LABEL_DATA resource.
One should keep in mind that setting Pt_ARG_LABEL_DATA causes the PtLabel to take a copy of the image structure. When it frees the image (because its Pt_ARG_LABEL_DATA is being changed or because the PtLabel is getting destroyed) it calles PhReleaseImage(), which only frees members specified by the flags. So, if no release flags were set in the structure when you set the resource, then nothing gets released. |
|