flat assembler
Message board for the users of flat assembler.

Index > IDE Development > FASMW (small) memory leak ?

Author
Thread Post new topic Reply to topic
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 14 Jun 2011, 16:00

When you select "OK" or "cancel",
where is the "DeleteObject" for the last call to this function

After changing font 10 times (preview) ...
the "preview_font_object" that was created during the last change,
is not deleted before leaving the dialogbox.
(only the last one)
Code:
;FASMW.ASM/proc AppearanceSetup
;----------------------------------
                .....
.change_font:   mov     esi,tmp_font
                mov     edi,backup_font
                mov     ecx,sizeof.LOGFONT shr 2
                rep     movsd
                invoke  ChooseFont,cf
                or      eax,eax
                jz      .change_font_cancelled
                invoke  SendDlgItemMessage,\
                [hwnd_dlg],ID_PREVIEW,WM_GETFONT,0,0
                mov     ebx,eax

                invoke  CreateFontIndirect,[cf.lpLogFont] ;<-----------------

                invoke  SendDlgItemMessage,\
                [hwnd_dlg],ID_PREVIEW,WM_SETFONT,eax,0
                invoke  DeleteObject,ebx
                jmp     .processed
                .....
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 14 Jun 2011, 16:00
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 14 Jun 2011, 16:13
The current font is deleted the next time you change to a new font. Only one font is active at any one time.
Post 14 Jun 2011, 16:13
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 14 Jun 2011, 17:02
Quote:

The current font is deleted the next time time you change to a new font
yes, but the last one is not deleted.
Quote:
Only one font is active at any one time.
sorry, i'm not agree with you.
When you are leaving the dialog box, there are two fonts active

The first one
Code:
.change_font:   mov     esi,tmp_font
                mov     edi,backup_font
                mov     ecx,sizeof.LOGFONT shr 2
                rep     movsd
                invoke  ChooseFont,cf
                or      eax,eax
                jz      .change_font_cancelled
                invoke  SendDlgItemMessage,\
                [hwnd_dlg],ID_PREVIEW,WM_GETFONT,0,0
                mov     ebx,eax
                invoke  CreateFontIndirect,[cf.lpLogFont] <-------------
    

and the second one
Code:
.ok:            
              mov     esi,tmp_colors
                mov     edi,editor_colors
                mov     ecx,colors_number
                rep     movsd
                mov     esi,tmp_font
                mov     edi,font
                mov     ecx,sizeof.LOGFONT shr 2
                rep     movsd
                invoke  CreateFontIndirect,font ;<--------------
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 14 Jun 2011, 17:02
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 14 Jun 2011, 17:06
Do you see the "DeleteObject" call? What is it deleting?
Post 14 Jun 2011, 17:06
View user's profile Send private message Visit poster's website Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 14 Jun 2011, 17:35

Code:
;1)
.change_font:
.....
invoke  CreateFontIndirect,[cf.lpLogFont] ;-----> object n°1

; where is the "mov [hfont],eax" ?

;----------------------------------------

;2)
.ok:
.....
invoke  CreateFontIndirect,font ;-----> object n°2

;xchg    eax,[hfont]
;invoke  DeleteObject,eax
    


The "DeleteObject" does not delete the object n°1 !
This "DeleteObject" deletes the object whose handle is contained in "[hfond]".
but the result_handle from CreateFontIndirect n°1 is not put in [hfond] ...
this handle (from CreateFontIndirect n°1) is not saved, this handle is lost !


_________________
I am not young enough to know everything (Oscar Wilde)- Image


Last edited by ouadji on 14 Jun 2011, 17:47; edited 1 time in total
Post 14 Jun 2011, 17:35
View user's profile Send private message Send e-mail Reply with quote
ouadji



Joined: 24 Dec 2008
Posts: 1081
Location: Belgium
ouadji 14 Jun 2011, 17:43

[tempo] != eax

this "DeleteObject" does not delete object n°1
Code:
;1)
tempo dd ?

.change_font:
.....
invoke  CreateFontIndirect,[cf.lpLogFont] ;--> object n°1

mov [tempo],eax

;----------------------------------------
;2)
.ok:
.....
invoke  CreateFontIndirect,font ;--> object n°2
xchg    eax,[hfont]

          ;<----- [tempo] != eax (syser debugger)

invoke  DeleteObject,eax
    

_________________
I am not young enough to know everything (Oscar Wilde)- Image
Post 14 Jun 2011, 17:43
View user's profile Send private message Send e-mail Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20344
Location: In your JS exploiting you and your system
revolution 14 Jun 2011, 17:48
You are right, a second font is active but not used.

However there is still no memory leak since that second inactive font (stored in hfont) is deleted next time the dialog is active.
Post 14 Jun 2011, 17:48
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.