consumption of memory / garbage collector

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

Post Reply
jpp
Posts: 34
Joined: Thu Jan 16, 2014 3:04 pm

consumption of memory / garbage collector

Post by jpp »

hi to all
still me.....

i've seen by using some apps i've made that memory consumption will allways increase without to store data in memory variable.
to see if the problem comes from my apps, i've made a small sample from 'grid03'

Code: Select all

#include "hmg.ch"

Function Main
	DEFINE WINDOW Form_1 ;
		AT 0,0 ;
		WIDTH 450 ;
		HEIGHT 400 ;
		TITLE 'Hello World!' ;
		MAIN 

		DEFINE MAIN MENU
			DEFINE POPUP 'File'
				MENUITEM 'Change ItemCount' ACTION Form_1.Grid_1.ItemCount := Val(InputBox('New Value','Change ItemCount'))
				MENUITEM 'test mem' action test()
			END POPUP
		END MENU

		@ 10,10 GRID Grid_1 ;
		WIDTH 400 ;
		HEIGHT 330 ;
		HEADERS {'','Column 2','Column 3'} ;
		WIDTHS {0,140,140};
		VIRTUAL ;
		ITEMCOUNT 100000000 ;
		ON QUERYDATA QueryTest() ;
		IMAGE {"br_no","br_ok"} CELLNAVIGATION ;
		VALUE { 1 , 2 }

	END WINDOW

	CENTER WINDOW Form_1

	ACTIVATE WINDOW Form_1

Return

Procedure QueryTest()
	If This.QueryColIndex == 1
		If Int ( This.QueryRowIndex / 2 ) == This.QueryRowIndex / 2
			This.QueryData := 0
		Else
			This.QueryData := 1
		EndIf
	Else
		This.QueryData := Str ( This.QueryRowIndex ) + ',' + Str ( This.QueryColIndex )
	EndIf
Return

proc test
for g:= 1 to 10
	for f:=1 to 1000
		_pushkey(VK_NEXT)
		do events
	next
	for f:=1 to 1000
		_pushkey(VK_PRIOR)
		do events
	next
next
return
-> After loading the program consume about 5200 K of memory ( windows task manager )
-> After running the 'test' it consume about 47500 K of memory
-> After running a second test it's about 88700 K

i really don't understand why, and even after a while memory usage remains the same

is there a way to free memory ?

Thanks
Post Reply