Details
-
Bug
-
Resolution: Unresolved
-
Major
-
None
-
None
Description
This ticket is about cases where the LR_SHARED flag is specified.
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-loadimagea
When you are finished using a bitmap, cursor, or icon you loaded without specifying the LR_SHARED flag, you can release its associated memory by calling one of the functions in the following table.
Resource Release function
Bitmap DeleteObject
Cursor DestroyCursor
Icon DestroyIcon
The system automatically deletes these resources when the process that created them terminates; however, calling the appropriate function saves memory and decreases the size of the process's working set.
—
https://docs.microsoft.com/en-us/windows/win32/api/wingdi/nf-wingdi-deleteobject
No specific remark; simply do not use it in this ticket context.
—
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-destroycursor
The DestroyCursor function destroys a nonshared cursor. Do not use this function to destroy a shared cursor. A shared cursor is valid as long as the module from which it was loaded remains in memory. The following functions obtain a shared cursor:
LoadCursor
LoadCursorFromFile
LoadImage (if you use the LR_SHARED flag)
CopyImage (if you use the LR_COPYRETURNORG flag and the hImage parameter is a shared cursor)
—
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-destroyicon
It is only necessary to call DestroyIcon for icons and cursors created with the following functions: CreateIconFromResourceEx (if called without the LR_SHARED flag), CreateIconIndirect, and CopyIcon. Do not use this function to destroy a shared icon. A shared icon is valid as long as the module from which it was loaded remains in memory. The following functions obtain a shared icon.
LoadIcon
LoadImage (if you use the LR_SHARED flag)
CopyImage (if you use the LR_COPYRETURNORG flag and the hImage parameter is a shared icon)
CreateIconFromResource
CreateIconFromResourceEx (if you use the LR_SHARED flag)