View previous topic :: View next topic |
Author |
Message |
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Fri Apr 17, 2009 2:38 am Post subject: VDS 6 Memory Leak |
|
|
Seems there's a memory leak in VDS 6. Not sure if it's limited to only using a timer loop, or in general, but I only found out while using a timer loop.
Here's a simple example to use and test to see if VDS 6 suffers from a memory leak on your system.
Compile it, run it, open Windows Task Manager, hit the Processes tab and look for your exe. Then just sit and watch for a few minutes. See if the memory continues to increase.
Code: | OPTION SLEEPTIME,20
DIALOG CREATE,New Dialog,-1,0,320,240
DIALOG ADD,STYLE,STYLE1,,14,BC,,BLACK
DIALOG ADD,STYLE,STYLE2,,12,,,BLACK
DIALOG ADD,SHAPE,SHAPE1,0,0,320,240,WHITE,BLACK,,RECTANGLE
DIALOG ADD,TEXT,TEXT1,20,0,320,24,VDS 6 Memory Leak Test,,STYLE1
DIALOG ADD,TEXT,TEXT2,60,20,280,100,Compile this example and then run it. Open Windows Task Manager and select the processes tab and seek out this program and watch the memory.,,STYLE2
DIALOG ADD,BUTTON,BUTTON1,205,245,64,24,Exit
DIALOG SHOW
:EVENTLOOP
WAIT EVENT,"0.0"
GOTO @event()
:BUTTON1BUTTON
:CLOSE
EXIT
:TIMER
GOTO EVENTLOOP |
_________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Fri Apr 17, 2009 2:47 am Post subject: |
|
|
Further checking it out, I find that the culprit is the timer event. Using "WAIT EVENT,<time here>" and any amount of time below 1 causes a leak.
Now if you were to use the following code without the timer in the WAIT EVENT, you get no leak at all.
Code: | OPTION SLEEPTIME,20
DIALOG CREATE,New Dialog,-1,0,320,240
DIALOG ADD,STYLE,STYLE1,,14,BC,,BLACK
DIALOG ADD,STYLE,STYLE2,,12,,,BLACK
DIALOG ADD,SHAPE,SHAPE1,0,0,320,240,WHITE,BLACK,,RECTANGLE
DIALOG ADD,TEXT,TEXT1,20,0,320,24,VDS 6 Memory Leak Test,,STYLE1
DIALOG ADD,TEXT,TEXT2,60,20,280,100,Compile this example and then run it. Open Windows Task Manager and select the processes tab and seek out this program and watch the memory.,,STYLE2
DIALOG ADD,BUTTON,BUTTON1,205,245,64,24,Exit
DIALOG SHOW
:EVENTLOOP
WAIT "0.0"
%E = @event()
IF %E
GOTO %E
END
GOTO EVENTLOOP
:BUTTON1BUTTON
:CLOSE
EXIT |
_________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
DaveR Valued Contributor
Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sat Apr 18, 2009 7:46 am Post subject: |
|
|
It seems like a very slow memory leak, but at around 2K per second that's 172800K per day. But as soon as you minimise, or minimise and restore, the window the memory usage drops a lot. If you minimised and then restored the window every 30 minutes the memory usage would never excede the original amount used when the application was first started.
Using 'wait event, 0.0'
When first started it uses 5000K.
After about 10 seconds it starts to leak at about 2K per second.
If you Minimise it, it drops to between 620 and 720K.
If you then Restore it, it jumps up to about 1500K.
Note: It continues to leak during all of the above. _________________ cheers
Dave
Last edited by DaveR on Sun Apr 19, 2009 5:51 am; edited 1 time in total |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sat Apr 18, 2009 9:52 am Post subject: |
|
|
That's odd, I didn't get any leak when I just used WAIT "0.1" or anything in that range, or WAIT 0, only when I used EVENT WAIT, "0.1" or anything below 1. _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
DaveR Valued Contributor
Joined: 03 Sep 2005 Posts: 413 Location: Australia
|
Posted: Sun Apr 19, 2009 5:50 am Post subject: |
|
|
Sorry, I meant:
Using 'wait event, 0.0' (not Using 'wait, 0.0'). I've corrected my post above.
Further testing has revealed that adding any conditional statement within the eventloop prevents the memory leak.
Code: | :EVENTLOOP
IF @EQUAL(%z,1)
END
WAIT EVENT,"0.0"
GOTO @event()
|
_________________ cheers
Dave |
|
Back to top |
|
|
Garrett Moderator Team
Joined: 04 Oct 2001 Posts: 2149 Location: A House
|
Posted: Sun Apr 19, 2009 3:36 pm Post subject: |
|
|
Oh no you didn't just totally trash my workaround that I went and edited some of my source codes already cuz there was no other workaround at the time then you come along with a more simple solution to the solution I already came up with............
I'm a kidding of course
Now I can go back to using the wait event again and just toss in a dud IF/END in there.
Thanks for doing more testing and finding that out Dave _________________ 'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.) |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|