forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Programs with defined functions "eat" more and mor

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
gonzabar
Newbie


Joined: 24 Jun 2001
Posts: 15
Location: Madrid, Spain

PostPosted: Thu Oct 09, 2003 11:59 am    Post subject: Programs with defined functions "eat" more and mor Reply with quote

Dos anyone knows why a program with defined functions "eat" more and more memory of system. Examples:

Program-1:

Code:
REM This program do not "eat" memory of system.
REM It don't use "defined functions"
REM
TITLE NO_EAT_MEMORY
DIALOG CREATE,NO_EAT_MEM,-1,0,400,240
dialog add,text,text1,10,10,300,70
dialog add,button,stop,100,10,300,70,STOP
dialog show
%%valor = 0
REM
REM infinite loop
REM
REPEAT
   %z = @event()
   if @equal(%z,stopbutton)
      goto %z
   end
   %%valor = @sum(%%valor,1)
   dialog set,text1,%%valor @CR() Free memory = @sysinfo(FREEMEM)
   if @greater(%%valor,20000)
      %%valor = 0
   end
UNTIL @EQUAL(%%valor,"nonsense")
:stopbutton
:close
exit


Program-2:

Code:
REM This program "eat", more and more, memory of system.
REM It use "defined function"
REM
REM Why ?
REM
TITLE EAT_MEMORY
DIALOG CREATE,EAT_MEM,-1,0,400,240
dialog add,text,text1,10,10,300,70
dialog add,button,stop,100,10,300,70,STOP
dialog show
%%valor = 0
REM Infinite loop
REPEAT
   %z = @event()
   if @equal(%z,stopbutton)
      goto %z
   end
   %%valor = @add_number(%%valor,1)
   dialog set,text1,%%valor @CR() Free memory = @sysinfo(FREEMEM)
   if @greater(%%valor,20000)
      %%valor = 0
   end
UNTIL @EQUAL(%%valor,"nonsense")
:stopbutton
:close
exit
#DEFINE FUNCTION, ADD_NUMBER
:add_number
   %x = @sum(%1,%2)
EXIT %x


Thanks, in advance



[ Edited by moderator: Added [ vds ] tags to better display code... ]
Back to top
View user's profile Send private message Send e-mail
CodeScript
Moderator Team


Joined: 08 Jun 2003
Posts: 1060
Location: India

PostPosted: Thu Oct 09, 2003 3:15 pm    Post subject: Reply with quote

Yes It does cause memory leak both on Xp and Win 98.
Shifting #DEFINE to the top doesnot help.
Loss is slower with "Gloabl variables" but it may simply be that they are slower
Any clues Rolling Eyes Confused

_________________
Regards
- CodeScript
Arrow Give your application a professional look with the VDSGUI Extension
Back to top
View user's profile Send private message Visit poster's website
Skit3000
Admin Team


Joined: 11 May 2002
Posts: 2166
Location: The Netherlands

PostPosted: Thu Oct 09, 2003 5:14 pm    Post subject: Reply with quote

Maybe it's because the VDS interpreter has to seek for some defined commands and functions, next to the ones it normally seeks for? I'm almost 100% sure that the variables aren't the problem, because they are all changed into a global variable when compiled (that's why there is a limited number of variables available)...
_________________
[ Add autocomplete functionality to your VDS IDE windows! ]
Voor Nederlandse beginners met VDS: bekijk ook eens deze tutorial!
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Thu Oct 09, 2003 6:00 pm    Post subject: Reply with quote

I'll look into it but I don't think @sysinfo(freemem) is a valid way to test for a memory leak because the Windows memory manager doesn't give back to the system every block of memory the instant a program frees it. That would be inefficient. Instead, it waits until a lot of memory is needed and then consolidates all the memory that has been freed into a block and adds it to the free memory pool. So what you're seeing is because the VDS interpreter allocates and then frees a block of memory for the local variables and stuff each time a function is called, which it doesn't do if you use a gosub.
_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
gonzabar
Newbie


Joined: 24 Jun 2001
Posts: 15
Location: Madrid, Spain

PostPosted: Thu Oct 09, 2003 8:00 pm    Post subject: Reply with quote

I have observed that the program (interpreted or compiled) no frees the blocks of memory allocated for local variables and stuff each time the function is called. If you run the program and wait (infinte loop), the amount of free memory is, finally, zero bytes.
Back to top
View user's profile Send private message Send e-mail
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Thu Oct 09, 2003 8:33 pm    Post subject: Reply with quote

Well, you are right (though I'm interested to know how you worked out what the leaked memory blocks were without the benefit of the VDS source code. Smile ) I always thought that Delphi was supposed to take care of the memory management of strings by itself, but obviously it doesn't.
_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Fri Sep 24, 2004 3:52 pm    Post subject: Memory Leak Reply with quote

I found a part solution to the memory leak issue. What I found is so simple it's stupid. If you’re running a dialog with your app all you have to do is minimize it. Window iconize doesn’t seam to work. But if you click on the minimize button the app will release the memory and start all over again. I'm betting there is a @sendmsg that you could send to the window to do something similar it might not even have to be a minimize funshion. who knows maybe a repaint would do it.
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Tue Sep 28, 2004 11:54 pm    Post subject: Reply with quote

This goes back to my recent posting(s) as follows:

http://forum.vdsworld.com/viewtopic.php?p=22644&highlight=#22644

When running my program, and after minimizing it as explained by Bbelcher, this FIXED the massive memory issue. I hope someone can figure out a way to accomplish this without having to click on the application's minimize button each time...

FYI: My application includes a lot of defined functions/commands...

Cheers,

- Boo
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Wed Sep 29, 2004 9:24 am    Post subject: Reply with quote

The issue with user defined commands and functions was a bug in VDS 5 that was fixed in the 5.01 update.

What's happening when you minimize an application is nothing to do with VDS, which doesn't even know if the app has been minimized or not. It's probably something to do with Windows freeing up the graphical resources used to display the application on screen, that are no longer needed when it isn't there any more.

Window iconize just sends a message to the window to minimize it, so I doubt if there is anything extra you can do using @sendmsg. I don't really see why it's a problem, since you don't appear to have a memory leak (which is when an app constantly uses more and more memory until Windows grinds to a halt.)

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Wed Sep 29, 2004 11:49 am    Post subject: Reply with quote

Jules,

I do have an app that keeps using more and more resources. Basically I'm using PGWARES VDSIPP dll to run a TFTP server and client. The TFTP server will keep climbing every time the TFTP client requests a download. If I run it in a loop I can easily get 30 Megs of memory use for the TFTP server portion. The TFTP server portion does not have a dialog. If I add a dialog then the minimize button on the dialog will release all that memory and it will start again at about 3 meg.

Here is some code that I'm useing.

Code:

rem   title EMAlert_helper2
rem   DIALOG CREATE, helper2,-1,0,260,45,
REM *** Modified by Dialog Designer on 9/24/2004 - 11:23 ***
rem  DIALOG SHOW
   
   
    external @path(%0)vdsipp.dll,
   #define command,internet
   #define function,internet
   

     repeat
        %%serverid = @sum(%%serverid,1)
      internet TFTP-SERVER,CREATE,%%serverid
    INTERNET TFTP-SERVER,ACTIVATE,%%serverid,69
    until @equal(%%serverid,99)
   
    :evloop
    wait event
goto @event()

   
    :TFTP-SERVER1ONGETFILEREQUEST
%%SERVERGETID = 1
goto tftptransfer
:TFTP-SERVER2ONGETFILEREQUEST
%%SERVERGETID = 2
goto tftptransfer
:TFTP-SERVER3ONGETFILEREQUEST
%%SERVERGETID = 3
goto tftptransfer
:TFTP-SERVER4ONGETFILEREQUEST
%%SERVERGETID = 4
goto tftptransfer
:TFTP-SERVER5ONGETFILEREQUEST
%%SERVERGETID = 5
goto tftptransfer
:TFTP-SERVER6ONGETFILEREQUEST
%%SERVERGETID = 6
goto tftptransfer
:TFTP-SERVER7ONGETFILEREQUEST
%%SERVERGETID = 7
goto tftptransfer
:TFTP-SERVER8ONGETFILEREQUEST
%%SERVERGETID = 8
goto tftptransfer
:TFTP-SERVER9ONGETFILEREQUEST
%%SERVERGETID = 9
goto tftptransfer
:TFTP-SERVER10ONGETFILEREQUEST
%%SERVERGETID = 10
goto tftptransfer
:TFTP-SERVER11ONGETFILEREQUEST
%%SERVERGETID = 11
goto tftptransfer
:TFTP-SERVER12ONGETFILEREQUEST
%%SERVERGETID = 12
goto tftptransfer
:TFTP-SERVER13ONGETFILEREQUEST
%%SERVERGETID = 13
goto tftptransfer
:TFTP-SERVER14ONGETFILEREQUEST
%%SERVERGETID = 14
goto tftptransfer
:TFTP-SERVER15ONGETFILEREQUEST
%%SERVERGETID = 15
goto tftptransfer
:TFTP-SERVER16ONGETFILEREQUEST
%%SERVERGETID = 16
goto tftptransfer
:TFTP-SERVER17ONGETFILEREQUEST
%%SERVERGETID = 17
goto tftptransfer
:TFTP-SERVER18ONGETFILEREQUEST
%%SERVERGETID = 18
goto tftptransfer
:TFTP-SERVER19ONGETFILEREQUEST
%%SERVERGETID = 19
goto tftptransfer
:TFTP-SERVER20ONGETFILEREQUEST
%%SERVERGETID = 20
goto tftptransfer
:TFTP-SERVER21ONGETFILEREQUEST
%%SERVERGETID = 21
goto tftptransfer
:TFTP-SERVER22ONGETFILEREQUEST
%%SERVERGETID = 22
goto tftptransfer
:TFTP-SERVER23ONGETFILEREQUEST
%%SERVERGETID = 23
goto tftptransfer
:TFTP-SERVER24ONGETFILEREQUEST
%%SERVERGETID = 24
goto tftptransfer
:TFTP-SERVER25ONGETFILEREQUEST
%%SERVERGETID = 25
goto tftptransfer
:TFTP-SERVER26ONGETFILEREQUEST
%%SERVERGETID = 26
goto tftptransfer
:TFTP-SERVER27ONGETFILEREQUEST
%%SERVERGETID = 27
goto tftptransfer
:TFTP-SERVER28ONGETFILEREQUEST
%%SERVERGETID = 28
goto tftptransfer
:TFTP-SERVER29ONGETFILEREQUEST
%%SERVERGETID = 29
goto tftptransfer
:TFTP-SERVER30ONGETFILEREQUEST
%%SERVERGETID = 30
goto tftptransfer
:TFTP-SERVER31ONGETFILEREQUEST
%%SERVERGETID = 31
goto tftptransfer
:TFTP-SERVER32ONGETFILEREQUEST
%%SERVERGETID = 32
goto tftptransfer
:TFTP-SERVER33ONGETFILEREQUEST
%%SERVERGETID = 33
goto tftptransfer
:TFTP-SERVER34ONGETFILEREQUEST
%%SERVERGETID = 34
goto tftptransfer
:TFTP-SERVER35ONGETFILEREQUEST
%%SERVERGETID = 35
goto tftptransfer
:TFTP-SERVER36ONGETFILEREQUEST
%%SERVERGETID = 36
goto tftptransfer
:TFTP-SERVER37ONGETFILEREQUEST
%%SERVERGETID = 37
goto tftptransfer
:TFTP-SERVER38ONGETFILEREQUEST
%%SERVERGETID = 38
goto tftptransfer
:TFTP-SERVER39ONGETFILEREQUEST
%%SERVERGETID = 39
goto tftptransfer
:TFTP-SERVER40ONGETFILEREQUEST
%%SERVERGETID = 40
goto tftptransfer
:TFTP-SERVER41ONGETFILEREQUEST
%%SERVERGETID = 41
goto tftptransfer
:TFTP-SERVER42ONGETFILEREQUEST
%%SERVERGETID = 42
goto tftptransfer
:TFTP-SERVER43ONGETFILEREQUEST
%%SERVERGETID = 43
goto tftptransfer
:TFTP-SERVER44ONGETFILEREQUEST
%%SERVERGETID = 44
goto tftptransfer
:TFTP-SERVER45ONGETFILEREQUEST
%%SERVERGETID = 45
goto tftptransfer
:TFTP-SERVER46ONGETFILEREQUEST
%%SERVERGETID = 46
goto tftptransfer
:TFTP-SERVER47ONGETFILEREQUEST
%%SERVERGETID = 47
goto tftptransfer
:TFTP-SERVER48ONGETFILEREQUEST
%%SERVERGETID = 48
goto tftptransfer
:TFTP-SERVER49ONGETFILEREQUEST
%%SERVERGETID = 49
goto tftptransfer
:TFTP-SERVER50ONGETFILEREQUEST
%%SERVERGETID = 50
goto tftptransfer
:TFTP-SERVER51ONGETFILEREQUEST
%%SERVERGETID = 51
goto tftptransfer
:TFTP-SERVER52ONGETFILEREQUEST
%%SERVERGETID = 52
goto tftptransfer
:TFTP-SERVER53ONGETFILEREQUEST
%%SERVERGETID = 53
goto tftptransfer
:TFTP-SERVER54ONGETFILEREQUEST
%%SERVERGETID = 54
goto tftptransfer
:TFTP-SERVER55ONGETFILEREQUEST
%%SERVERGETID = 55
goto tftptransfer
:TFTP-SERVER56ONGETFILEREQUEST
%%SERVERGETID = 56
goto tftptransfer
:TFTP-SERVER57ONGETFILEREQUEST
%%SERVERGETID = 57
goto tftptransfer
:TFTP-SERVER58ONGETFILEREQUEST
%%SERVERGETID = 58
goto tftptransfer
:TFTP-SERVER59ONGETFILEREQUEST
%%SERVERGETID = 59
goto tftptransfer
:TFTP-SERVER60ONGETFILEREQUEST
%%SERVERGETID = 60
goto tftptransfer
:TFTP-SERVER61ONGETFILEREQUEST
%%SERVERGETID = 61
goto tftptransfer
:TFTP-SERVER62ONGETFILEREQUEST
%%SERVERGETID = 62
goto tftptransfer
:TFTP-SERVER63ONGETFILEREQUEST
%%SERVERGETID = 63
goto tftptransfer
:TFTP-SERVER64ONGETFILEREQUEST
%%SERVERGETID = 64
goto tftptransfer
:TFTP-SERVER65ONGETFILEREQUEST
%%SERVERGETID = 65
goto tftptransfer
:TFTP-SERVER66ONGETFILEREQUEST
%%SERVERGETID = 66
goto tftptransfer
:TFTP-SERVER67ONGETFILEREQUEST
%%SERVERGETID = 67
goto tftptransfer
:TFTP-SERVER68ONGETFILEREQUEST
%%SERVERGETID = 68
goto tftptransfer
:TFTP-SERVER69ONGETFILEREQUEST
%%SERVERGETID = 69
goto tftptransfer
:TFTP-SERVER70ONGETFILEREQUEST
%%SERVERGETID = 70
goto tftptransfer
:TFTP-SERVER71ONGETFILEREQUEST
%%SERVERGETID = 71
goto tftptransfer
:TFTP-SERVER72ONGETFILEREQUEST
%%SERVERGETID = 72
goto tftptransfer
:TFTP-SERVER73ONGETFILEREQUEST
%%SERVERGETID = 73
goto tftptransfer
:TFTP-SERVER74ONGETFILEREQUEST
%%SERVERGETID = 74
goto tftptransfer
:TFTP-SERVER75ONGETFILEREQUEST
%%SERVERGETID = 75
goto tftptransfer
:TFTP-SERVER76ONGETFILEREQUEST
%%SERVERGETID = 76
goto tftptransfer
:TFTP-SERVER77ONGETFILEREQUEST
%%SERVERGETID = 77
goto tftptransfer
:TFTP-SERVER78ONGETFILEREQUEST
%%SERVERGETID = 78
goto tftptransfer
:TFTP-SERVER79ONGETFILEREQUEST
%%SERVERGETID = 79
goto tftptransfer
:TFTP-SERVER80ONGETFILEREQUEST
%%SERVERGETID = 80
goto tftptransfer
:TFTP-SERVER81ONGETFILEREQUEST
%%SERVERGETID = 81
goto tftptransfer
:TFTP-SERVER82ONGETFILEREQUEST
%%SERVERGETID = 82
goto tftptransfer
:TFTP-SERVER83ONGETFILEREQUEST
%%SERVERGETID = 83
goto tftptransfer
:TFTP-SERVER84ONGETFILEREQUEST
%%SERVERGETID = 84
goto tftptransfer
:TFTP-SERVER85ONGETFILEREQUEST
%%SERVERGETID = 85
goto tftptransfer
:TFTP-SERVER86ONGETFILEREQUEST
%%SERVERGETID = 86
goto tftptransfer
:TFTP-SERVER87ONGETFILEREQUEST
%%SERVERGETID = 87
goto tftptransfer
:TFTP-SERVER88ONGETFILEREQUEST
%%SERVERGETID = 88
goto tftptransfer
:TFTP-SERVER89ONGETFILEREQUEST
%%SERVERGETID = 89
goto tftptransfer
:TFTP-SERVER90ONGETFILEREQUEST
%%SERVERGETID = 90
goto tftptransfer
:TFTP-SERVER91ONGETFILEREQUEST
%%SERVERGETID = 91
goto tftptransfer
:TFTP-SERVER92ONGETFILEREQUEST
%%SERVERGETID = 92
goto tftptransfer
:TFTP-SERVER93ONGETFILEREQUEST
%%SERVERGETID = 93
goto tftptransfer
:TFTP-SERVER94ONGETFILEREQUEST
%%SERVERGETID = 94
goto tftptransfer
:TFTP-SERVER95ONGETFILEREQUEST
%%SERVERGETID = 95
goto tftptransfer
:TFTP-SERVER96ONGETFILEREQUEST
%%SERVERGETID = 96
goto tftptransfer
:TFTP-SERVER97ONGETFILEREQUEST
%%SERVERGETID = 97
goto tftptransfer
:TFTP-SERVER98ONGETFILEREQUEST
%%SERVERGETID = 98
goto tftptransfer
:TFTP-SERVER99ONGETFILEREQUEST
%%SERVERGETID = 99
goto tftptransfer

:tftptransfer
  %C = @internet(tftp-server,filename,%%SERVERGETID)
%%ext = @ext(%C)
%%name = @name(%C)
rem info %%name
   if @equal(%%ext,txt)
        if @equal(%%name,test)
       INTERNET TFTP-SERVER,ALLOWTRANSFER,%%SERVERGETID,YES,%C
   else
     INTERNET TFTP-SERVER,ALLOWTRANSFER,%%SERVERGETID,NO,%C
      end
      end

goto evloop
 
:TFTP-SERVER1ONPUTFILEREQUEST
%%SERVERGETID = 1
goto tftpput
:TFTP-SERVER2ONPUTFILEREQUEST
%%SERVERGETID = 2
goto tftpput
:TFTP-SERVER3ONPUTFILEREQUEST
%%SERVERGETID = 3
goto tftpput
:TFTP-SERVER4ONPUTFILEREQUEST
%%SERVERGETID = 4
goto tftpput
:TFTP-SERVER5ONPUTFILEREQUEST
%%SERVERGETID = 5
goto tftpput
:TFTP-SERVER6ONPUTFILEREQUEST
%%SERVERGETID = 6
goto tftpput
:TFTP-SERVER7ONPUTFILEREQUEST
%%SERVERGETID = 7
goto tftpput
:TFTP-SERVER8ONPUTFILEREQUEST
%%SERVERGETID = 8
goto tftpput
:TFTP-SERVER9ONPUTFILEREQUEST
%%SERVERGETID = 9
goto tftpput
:TFTP-SERVER10ONPUTFILEREQUEST
%%SERVERGETID = 10
goto tftpput
:TFTP-SERVER11ONPUTFILEREQUEST
%%SERVERGETID = 11
goto tftpput
:TFTP-SERVER12ONPUTFILEREQUEST
%%SERVERGETID = 12
goto tftpput
:TFTP-SERVER13ONPUTFILEREQUEST
%%SERVERGETID = 13
goto tftpput
:TFTP-SERVER14ONPUTFILEREQUEST
%%SERVERGETID = 14
goto tftpput
:TFTP-SERVER15ONPUTFILEREQUEST
%%SERVERGETID = 15
goto tftpput
:TFTP-SERVER16ONPUTFILEREQUEST
%%SERVERGETID = 16
goto tftpput
:TFTP-SERVER17ONPUTFILEREQUEST
%%SERVERGETID = 17
goto tftpput
:TFTP-SERVER18ONPUTFILEREQUEST
%%SERVERGETID = 18
goto tftpput
:TFTP-SERVER19ONPUTFILEREQUEST
%%SERVERGETID = 19
goto tftpput
:TFTP-SERVER20ONPUTFILEREQUEST
%%SERVERGETID = 20
goto tftpput
:TFTP-SERVER21ONPUTFILEREQUEST
%%SERVERGETID = 21
goto tftpput
:TFTP-SERVER22ONPUTFILEREQUEST
%%SERVERGETID = 22
goto tftpput
:TFTP-SERVER23ONPUTFILEREQUEST
%%SERVERGETID = 23
goto tftpput
:TFTP-SERVER24ONPUTFILEREQUEST
%%SERVERGETID = 24
goto tftpput
:TFTP-SERVER25ONPUTFILEREQUEST
%%SERVERGETID = 25
goto tftpput
:TFTP-SERVER26ONPUTFILEREQUEST
%%SERVERGETID = 26
goto tftpput
:TFTP-SERVER27ONPUTFILEREQUEST
%%SERVERGETID = 27
goto tftpput
:TFTP-SERVER28ONPUTFILEREQUEST
%%SERVERGETID = 28
goto tftpput
:TFTP-SERVER29ONPUTFILEREQUEST
%%SERVERGETID = 29
goto tftpput
:TFTP-SERVER30ONPUTFILEREQUEST
%%SERVERGETID = 30
goto tftpput
:TFTP-SERVER31ONPUTFILEREQUEST
%%SERVERGETID = 31
goto tftpput
:TFTP-SERVER32ONPUTFILEREQUEST
%%SERVERGETID = 32
goto tftpput
:TFTP-SERVER33ONPUTFILEREQUEST
%%SERVERGETID = 33
goto tftpput
:TFTP-SERVER34ONPUTFILEREQUEST
%%SERVERGETID = 34
goto tftpput
:TFTP-SERVER35ONPUTFILEREQUEST
%%SERVERGETID = 35
goto tftpput
:TFTP-SERVER36ONPUTFILEREQUEST
%%SERVERGETID = 36
goto tftpput
:TFTP-SERVER37ONPUTFILEREQUEST
%%SERVERGETID = 37
goto tftpput
:TFTP-SERVER38ONPUTFILEREQUEST
%%SERVERGETID = 38
goto tftpput
:TFTP-SERVER39ONPUTFILEREQUEST
%%SERVERGETID = 39
goto tftpput
:TFTP-SERVER40ONPUTFILEREQUEST
%%SERVERGETID = 40
goto tftpput
:TFTP-SERVER41ONPUTFILEREQUEST
%%SERVERGETID = 41
goto tftpput
:TFTP-SERVER42ONPUTFILEREQUEST
%%SERVERGETID = 42
goto tftpput
:TFTP-SERVER43ONPUTFILEREQUEST
%%SERVERGETID = 43
goto tftpput
:TFTP-SERVER44ONPUTFILEREQUEST
%%SERVERGETID = 44
goto tftpput
:TFTP-SERVER45ONPUTFILEREQUEST
%%SERVERGETID = 45
goto tftpput
:TFTP-SERVER46ONPUTFILEREQUEST
%%SERVERGETID = 46
goto tftpput
:TFTP-SERVER47ONPUTFILEREQUEST
%%SERVERGETID = 47
goto tftpput
:TFTP-SERVER48ONPUTFILEREQUEST
%%SERVERGETID = 48
goto tftpput
:TFTP-SERVER49ONPUTFILEREQUEST
%%SERVERGETID = 49
goto tftpput
:TFTP-SERVER50ONPUTFILEREQUEST
%%SERVERGETID = 50
goto tftpput
:TFTP-SERVER51ONPUTFILEREQUEST
%%SERVERGETID = 51
goto tftpput
:TFTP-SERVER52ONPUTFILEREQUEST
%%SERVERGETID = 52
goto tftpput
:TFTP-SERVER53ONPUTFILEREQUEST
%%SERVERGETID = 53
goto tftpput
:TFTP-SERVER54ONPUTFILEREQUEST
%%SERVERGETID = 54
goto tftpput
:TFTP-SERVER55ONPUTFILEREQUEST
%%SERVERGETID = 55
goto tftpput
:TFTP-SERVER56ONPUTFILEREQUEST
%%SERVERGETID = 56
goto tftpput
:TFTP-SERVER57ONPUTFILEREQUEST
%%SERVERGETID = 57
goto tftpput
:TFTP-SERVER58ONPUTFILEREQUEST
%%SERVERGETID = 58
goto tftpput
:TFTP-SERVER59ONPUTFILEREQUEST
%%SERVERGETID = 59
goto tftpput
:TFTP-SERVER60ONPUTFILEREQUEST
%%SERVERGETID = 60
goto tftpput
:TFTP-SERVER61ONPUTFILEREQUEST
%%SERVERGETID = 61
goto tftpput
:TFTP-SERVER62ONPUTFILEREQUEST
%%SERVERGETID = 62
goto tftpput
:TFTP-SERVER63ONPUTFILEREQUEST
%%SERVERGETID = 63
goto tftpput
:TFTP-SERVER64ONPUTFILEREQUEST
%%SERVERGETID = 64
goto tftpput
:TFTP-SERVER65ONPUTFILEREQUEST
%%SERVERGETID = 65
goto tftpput
:TFTP-SERVER66ONPUTFILEREQUEST
%%SERVERGETID = 66
goto tftpput
:TFTP-SERVER67ONPUTFILEREQUEST
%%SERVERGETID = 67
goto tftpput
:TFTP-SERVER68ONPUTFILEREQUEST
%%SERVERGETID = 68
goto tftpput
:TFTP-SERVER69ONPUTFILEREQUEST
%%SERVERGETID = 69
goto tftpput
:TFTP-SERVER70ONPUTFILEREQUEST
%%SERVERGETID = 70
goto tftpput
:TFTP-SERVER71ONPUTFILEREQUEST
%%SERVERGETID = 71
goto tftpput
:TFTP-SERVER72ONPUTFILEREQUEST
%%SERVERGETID = 72
goto tftpput
:TFTP-SERVER73ONPUTFILEREQUEST
%%SERVERGETID = 73
goto tftpput
:TFTP-SERVER74ONPUTFILEREQUEST
%%SERVERGETID = 74
goto tftpput
:TFTP-SERVER75ONPUTFILEREQUEST
%%SERVERGETID = 75
goto tftpput
:TFTP-SERVER76ONPUTFILEREQUEST
%%SERVERGETID = 76
goto tftpput
:TFTP-SERVER77ONPUTFILEREQUEST
%%SERVERGETID = 77
goto tftpput
:TFTP-SERVER78ONPUTFILEREQUEST
%%SERVERGETID = 78
goto tftpput
:TFTP-SERVER79ONPUTFILEREQUEST
%%SERVERGETID = 79
goto tftpput
:TFTP-SERVER80ONPUTFILEREQUEST
%%SERVERGETID = 80
goto tftpput
:TFTP-SERVER81ONPUTFILEREQUEST
%%SERVERGETID = 81
goto tftpput
:TFTP-SERVER82ONPUTFILEREQUEST
%%SERVERGETID = 82
goto tftpput
:TFTP-SERVER83ONPUTFILEREQUEST
%%SERVERGETID = 83
goto tftpput
:TFTP-SERVER84ONPUTFILEREQUEST
%%SERVERGETID = 84
goto tftpput
:TFTP-SERVER85ONPUTFILEREQUEST
%%SERVERGETID = 85
goto tftpput
:TFTP-SERVER86ONPUTFILEREQUEST
%%SERVERGETID = 86
goto tftpput
:TFTP-SERVER87ONPUTFILEREQUEST
%%SERVERGETID = 87
goto tftpput
:TFTP-SERVER88ONPUTFILEREQUEST
%%SERVERGETID = 88
goto tftpput
:TFTP-SERVER89ONPUTFILEREQUEST
%%SERVERGETID = 89
goto tftpput
:TFTP-SERVER90ONPUTFILEREQUEST
%%SERVERGETID = 90
goto tftpput
:TFTP-SERVER91ONPUTFILEREQUEST
%%SERVERGETID = 91
goto tftpput
:TFTP-SERVER92ONPUTFILEREQUEST
%%SERVERGETID = 92
goto tftpput
:TFTP-SERVER93ONPUTFILEREQUEST
%%SERVERGETID = 93
goto tftpput
:TFTP-SERVER94ONPUTFILEREQUEST
%%SERVERGETID = 94
goto tftpput
:TFTP-SERVER95ONPUTFILEREQUEST
%%SERVERGETID = 95
goto tftpput
:TFTP-SERVER96ONPUTFILEREQUEST
%%SERVERGETID = 96
goto tftpput
:TFTP-SERVER97ONPUTFILEREQUEST
%%SERVERGETID = 97
goto tftpput
:TFTP-SERVER98ONPUTFILEREQUEST
%%SERVERGETID = 98
goto tftpput
:TFTP-SERVER99ONPUTFILEREQUEST
%%SERVERGETID = 99
goto tftpput

:tftpput
%D = @internet(tftp-server,filename,%%SERVERGETID)
 INTERNET TFTP-SERVER,ALLOWTRANSFER,%%SERVERGETID,NO,%D
 goto evloop

 :close
 exit
Back to top
View user's profile Send private message
jules
Professional Member
Professional Member


Joined: 14 Sep 2001
Posts: 1043
Location: Cumbria, UK

PostPosted: Wed Sep 29, 2004 2:04 pm    Post subject: Reply with quote

How do you know it isn't the extension that's using the memory?

I have written dozens of utilities in VDS 5, many of which are designed to run all day long as system tray applications. I use them myself, and they have been downloaded and run by tens of thousands of people. I have never noticed, nor been told about, any tendency for these applications to eat memory.

The fact that the memory used appears to be reallocated when you minimize the window suggests that it is some Windows mechanism that causes this to happen. Because your app is using an external subsystem (Winsock) it may be that Windows decides that it's safe to do a memory cleanup when the app is minimized, since this may indicate that it is temprarily not being used.

There is a problem with TCP/IP under Windows in that you need a window to receive messages notifying the program of events. I use the VDS Internet Suite for my TCP apps, which as far as possible works synchronously and uses polling to avoid this. However, it does require a VDS window to be created in order to receive messages informing about connection attempts, if you want to implement a server.

The closest app I have to yours (using VDS Internet Suite) is StopAds, which blocks ads and other malicious sites by using a hosts file to reroute accesses to localhost, which serves a blank page using a tiny VDS-written web server. When I used Internet Explorer this server got hundreds of requests a day, but I have never noticed an extreme memory usage, nor have any of the other users. (Since I switched to Firefox it doesn't get much work: so far today it's blocked just 19 accesses!)

_________________
The Tech Pro
www.tech-pro.net
Back to top
View user's profile Send private message Visit poster's website
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1563

PostPosted: Wed Sep 29, 2004 2:07 pm    Post subject: Reply with quote

It could be the dll actually consuming the memory, I'm not certain if this is the case or not unless what you posted is the entire of your code.

I do have one question:

Code:

  repeat
    %%serverid = @sum(%%serverid,1)
    internet TFTP-SERVER,CREATE,%%serverid
    INTERNET TFTP-SERVER,ACTIVATE,%%serverid,69
  until @equal(%%serverid,99)



Why exactly are you doing that? You cannot open 99 servers all using the exact same port number. It shouldn't work and it's the incorrecte way to setup servers. A single server should be able to handle hundreds of clients simultaneously and also be able to handle multiple downloads from a single user without a problem. You do not need 1 server for 1 client for each download; which is what it appears you were doing?

The vdsipp servers work asynchronously, thus it does not wait to complete sending a file to a user before it can handle a new user which connects or if the same user requests another file before the first one has completed transfering.

There are timers which are created internally within the dll for each tcp, udp or tftp server; thus having all 99 open (the max) causes numerous timers to kick in and memory to be consumed. I suspect the cpu usage is also very high in your app.
Back to top
View user's profile Send private message
bbelcher
Contributor
Contributor


Joined: 30 Jul 2002
Posts: 172

PostPosted: Wed Sep 29, 2004 2:26 pm    Post subject: Reply with quote

Thanks for the correction PGWARE. I wasn’t sure if that would work or not. I could use a different port that’s not a big deal to me. What I'm going for is the fastest possible way to support up to a 1000 clients without a possibility of losing any download request due to the 10 second timeout period. Any Ideas.


Jules,
I'm not sure exactly what’s going on but I do appreciate all the ideas. I think what I'm going to do is put a timer above the wait event and if it reaches say 5 minutes without an event then start another instance of the TFTP helper app and kill the old one. I believe this should work.
Back to top
View user's profile Send private message
PGWARE
Web Host


Joined: 29 Dec 2001
Posts: 1563

PostPosted: Wed Sep 29, 2004 3:03 pm    Post subject: Reply with quote

Hello,
The 10 second timeout period only occurs when a 'ONGETFILEREQUEST ' event is triggered. Which gives YOU up to 10 seconds to respond with the command> INTERNET TFTP-SERVER,ALLOWTRANSFER,1,<value of yes/no>,<filename> to tell it either YES allow the download or NO do not allow download; as long as you respond fast enough there is no delay at all.

You should be able to setup something like this:

Code:

:TFTP-SERVER1ONGETFILEREQUEST
INTERNET TFTP-SERVER,ALLOWTRANSFER,1,YES,@INTERNET(TFTP-SERVER,FILENAME,1)
goto evloop


That will cause absolutely no delay and no timeout period. You probably however want to check the filename they are requesting, so they dont request something like c:\mypasswords.txt Wink
Back to top
View user's profile Send private message
Boo
Valued Contributor
Valued Contributor


Joined: 31 Oct 2003
Posts: 599
Location: Gulf Breeze, Florida USA

PostPosted: Tue Oct 26, 2004 1:25 am    Post subject: Reply with quote

See this posting for a solution to this problem:

http://www.vdsworld.com/forum/viewtopic.php?t=1253

Cheers,

- Boo
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
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

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group