I've modified your code to my programming style with BindEvent() instead of BindGadgetEvent(), it also has no performance problems on Firefox/Windows and Safari/macOS.
But using the memory analyses of Firefox I've found a map in spider.event that grows, please have a look at the debug output:
Code: Select all
Global log.s
Procedure Events()
Debug EventGadget()
EndProcedure
For k = 0 To 1000
Win = OpenWindow(#PB_Any, 0, 0, 200, 200, "Test")
But = ButtonGadget(#PB_Any, 0, 0, 100, 30, "Hello")
But2 = ButtonGadget(#PB_Any, 0, 40, 100, 30, "Hello")
But3 = ButtonGadget(#PB_Any, 0, 80, 100, 30, "Hello")
BindEvent(#PB_Event_Gadget, @Events(), Win, #PB_All, #PB_All)
UnbindEvent(#PB_Event_Gadget, @Events(), Win, #PB_All, #PB_All)
CloseWindow(Win)
Next
Win = OpenWindow(#PB_Any, 0, 0, 200, 200, "Test")
But = ButtonGadget(#PB_Any, 0, 0, 100, 30, "Hello")
But2 = ButtonGadget(#PB_Any, 0, 40, 100, 30, "Hello")
But3 = ButtonGadget(#PB_Any, 0, 80, 100, 30, "Hello")
BindEvent(#PB_Event_Gadget, @Events(), Win, #PB_All, #PB_All)
!v_log = JSON.stringify(spider.event, null, 4);
Debug log
Code: Select all
{
"map": {
"4_100000_-1_-1": {},
"7_100000_-1_-1": {},
"1_100001_-1_-1": {},
"1_100002_-1_-1": {},
"1_100003_-1_-1": {},
"1_100004_-1_-1": {},
"1_100005_-1_-1": {},
"1_100006_-1_-1": {},
"1_100007_-1_-1": {},
"1_100008_-1_-1": {},
"1_100009_-1_-1": {},
"1_100010_-1_-1": {},
"1_100011_-1_-1": {},
"1_100012_-1_-1": {},
"1_100013_-1_-1": {},
"1_100014_-1_-1": {},
"1_100015_-1_-1": {},
"1_100016_-1_-1": {},
.....
"1_100988_-1_-1": {},
"1_100989_-1_-1": {},
"1_100990_-1_-1": {},
"1_100991_-1_-1": {},
"1_100992_-1_-1": {},
"1_100993_-1_-1": {},
"1_100994_-1_-1": {},
"1_100995_-1_-1": {},
"1_100996_-1_-1": {},
"1_100997_-1_-1": {},
"1_100998_-1_-1": {},
"1_100999_-1_-1": {},
"1_101000_-1_-1": {},
"1_101001_-1_-1": {},
"1_101002_-1_-1": {}
},
"eventWindow": 0,
"eventObject": 0,
"eventType": 0,
"eventData": 0
}
Unfortunately I don't have an Android device at home now to test your code, but I will try it on a Sunmi M2 device on Monday at the office.