Page 1 of 1

unused plin clients left in memory

Posted: Thu 28. Jun 2018, 18:58
by MOlrich
Looking for a way to find and kill PLin clients from the API.
Have noticed the app has been leaving clients open if the app closes abnormally.
the clients can be seen with the plinstat.exe tool.
How can I detect these errant clients and then destroy them from the API?

I have tried getting there handle using the getavailablehardware function and then subsequent calls to
LIN_GetHardwareParam with hwpConnectedClients as the parameter
It does not show any clients even though plinstat.exe does.

How can I find the client if the hardware has already been disconnected?

Re: unused plin clients left in memory

Posted: Fri 29. Jun 2018, 08:35
by K.Wagner
Hello,

first of all you need a method to detect which clients have been created from your application. You can achieve this by using a name pattern like MyAPP_ClientX, so that you can recognize them (you have up to 48 characters available for the name).

Then, at each start of your program you could have a loop, a for-statement for instance, in which you check if a client with this name pattern exists. This is done using the function 'LIN_GetClientParam'. As "client handle" you use the value of the iteration, from 1 to n, where n is the maximum amount clients you may have.

Note that the API has no restriction on the amount of clients, so how many iterations you have to do is up to you. If a client with handle x has a name (parameter 'clpName ') that match your pattern, then you can delete this client x by using the function LIN_RemoveClient(x).

Code: Select all

This pseudocode shows that explained before. A for-statement iterates client handles from 1 to 64. A function call is used to check if the current client name matches a pattern. If it does, the client is removed:

for(byte hClient=1; hClient<=64; hClient++)
    if(LIN_GetClientParam(hClient, clpName, nameBuffer, 48) == errOK)
        if(ClientBelongsToApp(nameBuffer))
            if (LIN_RemoveClient(hClient) == errOK)
                MessageBox("Client %hClient% (%nameBuffer%) removed");
            else
                MessageBox("An Error occurred while removing a client");

Re: unused plin clients left in memory

Posted: Fri 29. Jun 2018, 15:29
by MOlrich
Thanks
Works great.
Did not realize the Handle was just an index, as opposed to a pointer to the object


Matt