Applies To:
  • CitectSCADA 5.xx

Summary:
I am using an Active X control to monitor some remote changes.  It works as expected but after some time my PC runs out of virtual memory.  My code fragments are shown below.  What is the problem?

FUNCTION
MainControl()
....
TimeCtl = CreateControlObject("Time Control", sControlName, 0, 0, 10, 10, "");
....
//start background task
IF TaskNew("UpdateStatus", "", 0) < 0 THEN
    Message("Update Monitor", "Error starting UpdateStatus Task", 16);
    RETURN FALSE;
    END
....
END

INT
FUNCTION
UpdateStatus()

INT ChangeIndex;

WHILE TRUE DO

    ChangeIndex = _ObjectGetProperty(TimeCtl, "ChangeIndex"); // Get local change index

    IF ChangeIndex <> MyChangeIndex THEN
        UpdateTransition(); // Update local control
    END

Sleep(1);
END

RETURN TRUE;

END 
 


Solution:
When executing Active X cicode functions to get object properties or to call methods a small amount of memory is allocated and reserved until the cicode function containing these calls has finished executing.  In your example a Task is created which continues to execute until the task is killed.  Instead you can use the Task to call a separate cicode function which obtains the object properties etc.

INT
FUNCTION
UpdateStatus()

WHILE TRUE DO
    UpdateStatusGet();
    Sleep(1); // Wait 1 second
END

RETURN TRUE;

END

INT
FUNCTION
UpdateStatusGet()

INT ChangeIndex;

ChangeIndex = _ObjectGetProperty(TimeCtl, "ChangeIndex"); // Get local change index

IF ChangeIndex <> MyChangeIndex THEN
UpdateTransition(); // Update local control
END

RETURN TRUE;

END

CIT has confirmed this to be a problem in Citect for Windows version 5.00 to 5.21. We are researching this problem and will post new information here as it becomes available. 


Keywords:
ActiveX 

Attachments