The STATUSBAR control has a BUG

Moderator: Rathinagiri

huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

The STATUSBAR control has a BUG

Post by huiyi_ch »

各位大师,你们好,
近日我发现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 10879 times
Last edited by huiyi_ch on Mon Aug 19, 2019 9:56 am, edited 5 times in total.
User avatar
dragancesu
Posts: 920
Joined: Mon Jun 24, 2013 11:53 am
DBs Used: DBF, MySQL, Oracle
Location: Subotica, Serbia

Re: The STATUSBAR control has a BUG

Post by dragancesu »

Why loop WHILE 1=1 ???
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: The STATUSBAR control has a BUG

Post by huiyi_ch »

为了证实这个控件存在的问题!
In order to verify the problem with this control!
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: The STATUSBAR control has a BUG

Post by edk »

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: 172
Joined: Sat May 21, 2016 5:27 am

Re: The STATUSBAR control has a BUG

Post by huiyi_ch »

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: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: The STATUSBAR control has a BUG

Post by serge_girard »

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
There's nothing you can do that can't be done...
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: The STATUSBAR control has a BUG

Post by huiyi_ch »

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: 172
Joined: Sat May 21, 2016 5:27 am

Re: The STATUSBAR control has a BUG

Post by huiyi_ch »

Hello Grigory,
the StatusBar control in MINIGUI has no memory leak problem! Please you help solve the problems if possible.
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: The STATUSBAR control has a BUG

Post by huiyi_ch »

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.
huiyi_ch
Posts: 172
Joined: Sat May 21, 2016 5:27 am

Re: The STATUSBAR control has a BUG

Post by huiyi_ch »

srvet_claudio教授您好,
看到您又出现在论坛上,我非常高兴和激动!我觉得HMG又有希望了。在使用HMG的过程中,我发现statusbar control有一个BUG,并发贴到群里寻求解决,但问题一直悬而未决。请老师帮助这个问题。

I am very happy and excited to see you on the forum again! I think THERE's hope for HMG again. In the process of using HMG, I found a BUG in statusBar Control and posted it to the group for resolution, but the problem remained unresolved. Ask the teacher to help with this problem. Thank you very much!

huiyi_ch wrote: 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
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