The STATUSBAR control has a BUG

Moderator: Rathinagiri

Post Reply
huiyi_ch
Posts: 103
Joined: Sat May 21, 2016 5:27 am
Has thanked: 2 times
Been thanked: 12 times

The STATUSBAR control has a BUG

Post by huiyi_ch » Sun Aug 18, 2019 1:21 pm

各位大师,你们好,
近日我发现HMG(V3.4.4)中的STATUSBAR控件存在BUG,当我们不停地向STATUSBAR控件赋值时,程序所占有用的内存也在不断地增加!当你打开任务管理器可发现这一现象。请大家帮助我解决这一问题。
Dear masters,
Recently, I found a BUG in the STATUSBAR control in HMG(V3.4.4). When we keep assigning values to the STATUSBAR control, the memory occupied by the program keeps increasing!You can see this when you open task manager. Please help me solve this problem.

Code: Select all

#include "hmg.ch"
Function Main
	SET DATE ANSI
	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 ;
		HEIGHT 400 ;
		TITLE 'Statusbar Keyboard Demo' ;
		MAIN 
		DEFINE STATUSBAR FONT 'Arial' SIZE 9
			STATUSITEM "Statusbar Demo" 
		END STATUSBAR
		define button bt_1
		ROW    160
                COL    270
                WIDTH  100
                HEIGHT 28
               ACTION test_statusBar()
                CAPTION "Test"
		END button
 
	END WINDOW
	CENTER WINDOW Form_1
	ACTIVATE WINDOW Form_1
Return

function test_statusBar()
 while 1=1
    Form_1.StatusBar.Item(1):="I like HMG very much!"
	hb_idlesleep(0.1)
	do events
 end
return
test.jpg
test.jpg (77.88 KiB) Viewed 905 times
Last edited by huiyi_ch on Mon Aug 19, 2019 9:56 am, edited 5 times in total.

User avatar
dragancesu
Posts: 681
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia
Has thanked: 22 times
Been thanked: 139 times

Post by dragancesu » Mon Aug 19, 2019 9:34 am

Why loop WHILE 1=1 ???

huiyi_ch
Posts: 103
Joined: Sat May 21, 2016 5:27 am
Has thanked: 2 times
Been thanked: 12 times

Post by huiyi_ch » Mon Aug 19, 2019 9:47 am

为了证实这个控件存在的问题!
In order to verify the problem with this control!

edk
Posts: 480
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland
Has thanked: 136 times
Been thanked: 387 times

Post by edk » Mon Aug 19, 2019 2:23 pm

Maybe try to use RELEASE MEMEORY :idea:

Code: Select all

#include "hmg.ch"
Function Main

	SET DATE ANSI
	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 640 ;
		HEIGHT 400 ;
		TITLE 'Statusbar Keyboard Demo' ;
		MAIN 
		DEFINE STATUSBAR FONT 'Arial' SIZE 9
			STATUSITEM "Statusbar Demo" 
		END STATUSBAR
		define button bt_1
		ROW    160
                COL    270
                WIDTH  100
                HEIGHT 28
               ACTION test_statusBar()
                CAPTION "Start"
		END button
 
	END WINDOW
	CENTER WINDOW Form_1
	ACTIVATE WINDOW Form_1
Return

function test_statusBar()
IF Form_1.bt_1.Caption = 'Stop' 
	Form_1.bt_1.Caption := 'Start'
	Form_1.StatusBar.Item(1):=""
else
	Form_1.bt_1.Caption := 'Stop'
	while Form_1.bt_1.Caption = 'Stop'
		Form_1.StatusBar.Item(1):="I like HMG very much! " + time()
		RELEASE MEMORY
		HB_ReleaseCPU()
		hb_idlesleep(0.1)
		do events
	end	
endif

RELEASE MEMORY
HB_ReleaseCPU()

return

huiyi_ch
Posts: 103
Joined: Sat May 21, 2016 5:27 am
Has thanked: 2 times
Been thanked: 12 times

Post by huiyi_ch » Mon Aug 19, 2019 10:51 pm

EDK老师,您好,
我测试了您修改过的程序。长时间运行程序,再也没有发现程序占用内存增加的问题。
您是一个计算机方面的天才!谢谢!
我很喜欢HMG,经常使用它编写一些小程序。但现在HMG处于无人维护的阶段。我发现您完全可以胜任优化完善HMG的工作。

Dear Mr. EDK,
I tested your modified program.Run the program for a long time, and no more increase in memory usage.
You are a computer genius!Thank you very much!
I love HMG and often use it to write small programs.But HMG is now in a state of unattended maintenance.I find that you are fully qualified to optimize HMG.

User avatar
serge_girard
Posts: 2334
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Has thanked: 576 times
Been thanked: 124 times
Contact:

Post by serge_girard » Tue Aug 20, 2019 3:20 pm

Edward,

Is it a good idea to install a timer (every 10 minutes or so) which will do a RELEASE MEMORY and HB_ReleaseCPU() ?

Serge

huiyi_ch
Posts: 103
Joined: Sat May 21, 2016 5:27 am
Has thanked: 2 times
Been thanked: 12 times

Post by huiyi_ch » Thu Aug 22, 2019 1:19 am

Edward及各位老师,
使用RELEASE MEMORY是解决StatusBar的权宜之计,同时,在线程中使用RELEASE MEMORY会出现意想不到的问题。所以请大师们从根本上解决StatusBar存在的问题。另外,MINIGUI中的StatusBar控件没有内存增加的问题。

Dear Mr. EDK and the Teachers ,
The use of RELEASE MEMORY is an expedient solution to StatusBar. At the same time, the use of RELEASE MEMORY in threads can cause unexpected problems. So please the masters to fundamentally solve the problems in StatusBar. In addition, the StatusBar control in MINIGUI has no memory gain problem.

huiyi_ch
Posts: 103
Joined: Sat May 21, 2016 5:27 am
Has thanked: 2 times
Been thanked: 12 times

Post by huiyi_ch » Sun Aug 25, 2019 12:08 am

Hello Grigory,
the StatusBar control in MINIGUI has no memory leak problem! Please you help solve the problems if possible.

huiyi_ch
Posts: 103
Joined: Sat May 21, 2016 5:27 am
Has thanked: 2 times
Been thanked: 12 times

Post by huiyi_ch » Mon Aug 26, 2019 10:03 am

Hello guys,
After experiment, StatusBar control memory leak exists only in the Unicode Library of hmg.3.4.4, and no problem is found in the ANSI library of hmg.3.4.4.

Post Reply