Applies to:
PcVue all versions. |
||||||||||||||||
|
||||||||||||||||
Summary:
This article gives advice on using buffers in SCADA BASIC programs. It also provides a way of checking whether an application handles the buffers correctly. |
||||||||||||||||
|
||||||||||||||||
Details:
There are several SCADA BASIC functions that use buffers (e.g. SVTREND and SELECTOR). Before using any of these functions, it is necessary to allocate a buffer (i.e. a block of memory) with ALLOC_BUFFER. ALLOC_BUFFER returns a handle that is used subsequently for referencing the reserved memory area. Problem An important issue in programming is that of freeing all the memory that has been reserved. Otherwise, the application occupies excess memory which may cause erroneous operation of the operating system. You must check that the logic of your program includes provision to free its allocated buffers in all execution conditions. The verb FREE_BUFFER is used to free an allocated buffer.
Example This example allocates a buffer, then frees it after use if it is still allocated: Buf = FILETOBUF( file ); FREE_BUFFER( Buf ); End if In the example, if the file does not exist then buf is null (= 0). When FREE_BUFFER is used on a null handle, it generates an error.
To check whether your application is dealing correctly with buffers, you can examine the PcVue log files called Audit.Counters.xxxx.txt located in the PcVue\Bin\Log Files\ folder. In those files, towards the end of file, a line shows: [ ALLOC_BUFFER count ] Current = xxx Cumulative = yyy Current allocated memory = zzz
|
||||||||||||||||
|
||||||||||||||||
|
Created on: 05 Nov 2010 Last update: 26 Aug 2024