VFP TIMER MEMORY PROBLEM

Hi All,

Our product is a 24/7 Hospital product and i face a critical issue in Timer control.

The below code is a small example of my process, i created an exe of this code and this runs as a process in the task manager. The issue is this eats up memory consistently in time intervals.

if this exe is ran for days the memory is used is like in MBs and slowing down the PC's performance.

TimerCtrl()

procedure TimerCtrl

LOCAL poTim

poTim = createobject( "iTimer")

poTim.interval = 1000

poTim.enabled = .t.

read events

endproc

*=========================================================================================================================

define class iTimer as timer

function timer

RETURN

ENDFUNC

enddefine

I tried using the memory allocation command in the Timer Event to limit to 6800 KB but it didnt work.

= sys(3050, 2, 6800 * 1024)

My scenario is like this we have some files in a folder from another application which i have to access constantly in a time interval of one second and read the files separate the tokens and put in my Applications DBF.

do we have any other way we can do this in VFP.

i tried with DO While .t. Loop but its eating up the processor time upto 50% which is too costly for our customer.

Please suggest me some solution where i can limit the memory usage.

Kindly Advice me.

Thanks in advance

-Venkatram




Answer this question

VFP TIMER MEMORY PROBLEM

  • thewanz

    Venkatram,

    I ran this slightly modified version of the code you posted for 6 days, and here's how the VFP8 memory usage changed over time: 

    day time mem  vm

    Fri 0945 6168 2504
    Fri 0052 6220 2492
    Sat 0743 6228 2492
    screen resized
    Sat 0825 6616 2496 after move and some IEs displayed over it
    Sun 1104 6648 2496
    Mon 0830 6656 2496
    Tue 0927 6680 2496
    Wed 0900 6744 2496

    At the end it displayed that it had run 429391 timer hits. That's less that 600kb memory consumption over the test period. VFP does internally use some memory for screen painting, you can see the jump after I'd been using the box to do some web surfing and the browser windows were covering the app window. Perhaps if you tell us more about the code you actually have in the Timer.Timer() event we can recommend some other things for you to look at to solve the problem.

    private iCount
    iCount = 0

    on shutdown clear events

    LOCAL poTim

    poTim = createobject( "iTimer")

    poTim.interval = 1000

    poTim.enabled = .t.

    read events
    on shutdown

    messagebox( "how many:" + transform( iCount ) )

    return


    define class iTimer as timer

    function timer
    iCount = iCount + 1
    RETURN
    ENDFUNC
    enddefine



  • akeiii

    The timer routine is not the one eating memory. You must have some memory sink somewhere in  your program. Probably you are instantiating an object or three that you are not clearing. Make sure you do some garbage collection by releasing all objects and to make extra sure make the variable that holds the object reference = null

    See also: http://fox.wikis.com/wc.dll Wiki~OOP,GarbagecollectionAndDanglingObjectReferences... 

     

    As per the Timer routine, if you want you can replace it with the Sleep API:

    DECLARE Sleep IN kernel32 INTEGER dwMilliseconds

    * then when you need to wait a second:

    Sleep(1000)

     


  • BarryK

    > My scenario is like this we have some files in a folder from
    > another application which i have to access constantly in a time
    > interval of one second and read the files separate the tokens and > put in my Applications DBF.

    > do we have any other way we can do this in VFP

    Hi

    There are two ways I can think of:

    1) If you have VFP9, there's a sample in the Solutions app showing how to use BindEvents to watch a folder for new files - this will only work for a folder on the local computer though.

    2) For earlier versions, use WMI events to watch the directory: there is example code in
    http://weblogs.foxite.com/stuartdunkeld/archive/2005/09/16/915.aspx which watches c:\temp for new files. This might work remotely though I haven't tried it.

    Regards

    Stuart Dunkeld

  • graab

    >the code which i had given in the forum is creating the problem. i build an exe with this code in a PRG, when i execute this it starts using memory around 6MB and starts consistently eating up memory in time intervals.

    Not so, unless it does something else you are not showing. Your example above only shows a timer. A timer is used to trigger something, like the launching of a routine or program. By itself it should not consume any memory or use any other resources.


  • Joe August

    Hi Alex,

    the code which i had given in the forum is creating the problem. i build an exe with this code in a PRG, when i execute this it starts using memory around 6MB and starts consistently eating up memory in time intervals.

    is there any WinApi which we cna use to reset the memory in the Timer Event ot Limit the usage of memory.

    Thanks in advance.

    -Venkatram



  • Martin Herak

    Are you sure you're creating only one timer

    Tamar

  • VFP TIMER MEMORY PROBLEM