Memory leak with last xbrowse

Memory leak with last xbrowse

Postby Marco Turco » Mon Jan 03, 2011 8:17 pm

Hi,
I think there is a memory leak problem or problem with fonts with this last xbrowse version.
When I open a close more times an xbrowse than the xbrowse font and also the dialog fonts change in a bold style.

This is the xbrowse the first time it is executed on www.softwarexp.co.uk/beta/image1.png
This is the xbrowse the thirth time it is executed on www.softwarexp.co.uk/beta/image2.png

All runs fine using the Feb 2010 xBrowse version.

Any ideas ? Is a self-contained sample needed to check the problem ?
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Memory leak with last xbrowse

Postby Richard Chidiak » Tue Jan 04, 2011 5:24 am

Marco

I add this to my main program

SetKey( VK_F11, { || FERASE("CHECKRES.TXT"),CHECKRES() } )

This way i can always check memory leaks if necessary

I am using fwh 10.10 and fonts are ok with xbrowse

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Re: Memory leak with last xbrowse

Postby Marco Turco » Tue Jan 04, 2011 9:00 am

Hi,
this is a self-contained sample that shows the problem.
if you select "Show browse" then the xbrowse will be showed and closed automatically for 30 times,
check the xbrowse fonts and you will see that it will be crazy after 3-4 time the xbrowse is showed.
Perhaps the problem is relate to the xbrowse using in a ownClient and folder environment.

Any - urgent - solution ? :(
Thanks in advance.

----

#include "FiveWin.ch"
#include "folder.ch"
#include "xbrowse.ch"

function Main()
local oBtn, oDlg,aNames,aArray, oBrw2, oCol

DEFINE WINDOW oWnd ;
Title "test";
color nrgb(0,0,0),nrgb(255,255,255);
MENU BUILDMENU();
MDI


ACTIVATE WINDOW oWnd MAXIMIZED


function BuildMenu()

local oMenu
local oFirst, oSecond
local oItHelp

MENU oMenu
MENUITEM "&Test"
MENU
MENUITEM "Show xbrowse" ;
ACTION TestBrowse()
ENDMENU

ENDMENU

return oMenu


function testbrowse()
local oBrw1, obrw2,oBtn,i,ofld

aArray:=BrwGetData()

for i:=1 to 30

@1,1 XBROWSE oBrw1 ARRAY AARRAY OF oWnd:oWndClient SIZE 200,400
ADD COLUMN oCol TO XBROWSE oBrw1 DATA ARRAY ELEM 1;
HEADER "Num" SIZE 80
ADD COLUMN oCol TO XBROWSE oBrw1 DATA ARRAY ELEM 2;
HEADER "Type" SIZE 200
oBrw1:CreateFromCode()

@ 1, 40 FOLDER oFld PROMPT "&Test" ;
OF oWnd:oWndClient SIZE 500,500

@2,5 XBROWSE oBrw2 ARRAY AARRAY OF oFld SIZE 200,400
ADD COLUMN oCol TO XBROWSE oBrw2 DATA ARRAY ELEM 1;
HEADER "Num" SIZE 80
ADD COLUMN oCol TO XBROWSE oBrw2 DATA ARRAY ELEM 2;
HEADER "Type" SIZE 200
oBrw2:CreateFromCode()

sysrefresh()
syswait(1)
if i<30
oBrw1:End()
oBrw2:End()
oFld:End()
endif
next
return

Function BrwGetData()
local aArray

aArray:=array(0,4)
aadd(aArray,{1,"RED"})
aadd(aArray,{2,"GREEN"})
aadd(aArray,{2,"GREEN"})
aadd(aArray,{1,"RED"})
return(aArray)
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Memory leak with last xbrowse

Postby Marco Turco » Tue Jan 04, 2011 9:03 am

The self-contained executable is also available on www.softwarexp.co.uk/beta/xtest.zip
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Memory leak with last xbrowse

Postby nageswaragunupudi » Tue Jan 04, 2011 9:16 am

#1. MDI frame ( by using oWndClient or otherwise ) is not recommended to contain controls. Controls are to be placed in mdichild windows or dialogs. Yes, some of us found a workaround where by we are able to show some controls on oWndClient and using it at our own risk, but FWH does not support or guarantee this usage.

I agree, Mr. Antonio has a final word on this. Definitely not me. This is only my understanding.

#2. To isolate the problem, whether it is with xbrowse or oWndClient or folder class, better we perform this test ( repeat open and close ) on a normal window or dialog. Even then if it is a problem, then we have to search for a solution within xbrowse code.

To the best of my knowledge there were no recent changes in xbrowse which could mess up resources.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10306
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Memory leak with last xbrowse

Postby Marco Turco » Tue Jan 04, 2011 10:11 am

Hi,
this problem appears also without using oWndClient. See code attached.
Note that if I use the Fhw oct 2009 xbrowse class with FWH dec 2010 all runs fine.
If can help, you can download the fwh oct 2009 class from www.softwarexp.co.uk/beta/xbrowse_oct2009.zip

Unfortunately I need to solve the problem with this last xbrowse class because the october 2009 xbrowse class didn't manage empty arrays.



#include "FiveWin.ch"
#include "folder.ch"
#include "xbrowse.ch"

function Main()
local oBtn, oDlg,aNames,aArray, oBrw2, oCol

DEFINE WINDOW oWnd ;
Title "test";
color nrgb(0,0,0),nrgb(255,255,255);
MENU BUILDMENU()


ACTIVATE WINDOW oWnd MAXIMIZED


function BuildMenu()

local oMenu
local oFirst, oSecond
local oItHelp

MENU oMenu
MENUITEM "&Test"
MENU
MENUITEM "Show xbrowse" ;
ACTION TestBrowse()
ENDMENU

ENDMENU

return oMenu


function testbrowse()
local oBrw1, obrw2,oBtn,i,ofld

aArray:=BrwGetData()

for i:=1 to 30

@1,1 XBROWSE oBrw1 ARRAY AARRAY OF oWnd SIZE 200,400
ADD COLUMN oCol TO XBROWSE oBrw1 DATA ARRAY ELEM 1;
HEADER "Num" SIZE 80
ADD COLUMN oCol TO XBROWSE oBrw1 DATA ARRAY ELEM 2;
HEADER "Type" SIZE 200
oBrw1:CreateFromCode()

@ 1, 40 FOLDER oFld PROMPT "&Test" ;
OF oWnd SIZE 500,500

@2,5 XBROWSE oBrw2 ARRAY AARRAY OF oFld SIZE 200,400
ADD COLUMN oCol TO XBROWSE oBrw2 DATA ARRAY ELEM 1;
HEADER "Num" SIZE 80
ADD COLUMN oCol TO XBROWSE oBrw2 DATA ARRAY ELEM 2;
HEADER "Type" SIZE 200
oBrw2:CreateFromCode()

sysrefresh()
syswait(1)
if i<30
oBrw1:End()
oBrw2:End()
oFld:End()
endif
next
return

Function BrwGetData()
local aArray

aArray:=array(0,4)
aadd(aArray,{1,"RED"})
aadd(aArray,{2,"GREEN"})
aadd(aArray,{2,"GREEN"})
aadd(aArray,{1,"RED"})
return(aArray)
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Memory leak with last xbrowse

Postby ADutheil » Tue Jan 04, 2011 12:50 pm

I´am sometime having a similar problem since FWH9.11 but not with xBrowse. Simple dialogs without MDI on reopen change font. It still happens in FWH10.11.

Image
Image

I solved the problem by defining a font:
DEFINE FONT oFnt NAME "Ms Shell Dlg" SIZE 0, -10
DEFINE DIALOG oDlgp RESOURCE "PESQFOT" OF wndMain() FONT oFnt
...

André
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: Memory leak with last xbrowse

Postby nageswaragunupudi » Tue Jan 04, 2011 12:54 pm

Mr. Marco

I have tested your sample.
Problem seems to be with folders.

After the line:

@ 1, 40 FOLDER oFld PROMPT "&Test" ;
OF oWnd SIZE 500,500

Please add this line:
oFld:SetFont( oWnd:oFont )

Please test with this change and let us know the result please.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10306
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Memory leak with last xbrowse

Postby nageswaragunupudi » Tue Jan 04, 2011 12:56 pm

Mr. ADutheil

Like Mr. Marco, can you kindly prepare and small sample to show the problem? Let us try to find where the problem is.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10306
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Memory leak with last xbrowse

Postby Marco Turco » Tue Jan 04, 2011 1:39 pm

Great !! Adding oFld:SetFont( oWnd:oFont ) all seem to runs well (tested on 1000 open/close).

Do you think could it be possible to fix directly the tFolder class (or the FWH class related to the problem) ?
Best Regards,

Marco Turco
SOFTWARE XP LLP
User avatar
Marco Turco
 
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London

Re: Memory leak with last xbrowse

Postby ADutheil » Tue Jan 04, 2011 1:43 pm

You can download a test sample from ftp://200.223.215.215/tst.zip

Compile and run. Select "consulta" from main menu. A dialog opens. Close it with button "Cancelar".

If you change foto_con.prg
DEFINE DIALOG oDlgp RESOURCE "PESQFOT" OF wndMain() FONT oFnt
to
DEFINE DIALOG oDlgp RESOURCE "PESQFOT" OF wndMain()

when you reopen the dialog the font of the buttons is bold.

Andre
Regards,

André Dutheil
FWH 13.04 + HB 3.2 + MSVS 10
ADutheil
 
Posts: 368
Joined: Sun May 31, 2009 6:25 pm
Location: Salvador - Bahia - Brazil

Re: Memory leak with last xbrowse

Postby James Bott » Tue Jan 04, 2011 2:21 pm

I remember having a bold font issue when ending a font before the window was ended. Example:

define font oFont
define window oWnd
activate window oWnd
oFont:end()

Instead the proper syntax would be:

activate window oWnd valid( oFont:end(), .t.)

This solved the bold font problem in my case. I don't know if this is relevant the problem being discussed.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Memory leak with last xbrowse

Postby nageswaragunupudi » Tue Jan 04, 2011 2:30 pm

Mr. James

This does not appear to be the case here, because fonts are not explicitly created or released anywhere in the application.

It appears that folder object is decrementing the font usage counter without first incrementing it. So the workaround oFld:SetFont() seems to work. SetFont() increments the usage counter and this compensates decrementing the counter when the folder ends.
I am yet to see the source code of the folder.prg.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10306
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Memory leak with last xbrowse

Postby James Bott » Tue Jan 04, 2011 2:42 pm

Rao,

It appears that folder object is decrementing the font usage counter without first incrementing it.


Ah, this is really the same problem though. The font is ended while still in use. This is not a memory leak problem.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Memory leak with last xbrowse

Postby nageswaragunupudi » Tue Jan 04, 2011 2:54 pm

Mr. Marco
Do you think could it be possible to fix directly the tFolder class (or the FWH class related to the problem) ?

After we first study the code of folder.prg and make sure what we are suspecting is true, then we can suggest to Mr. Antonio
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10306
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: cmsoft and 63 guests