Hi everyone,
I am writing a program to read and write something through USB to Bluetooth HID. By calling CreateFile with FILE_SHARE_READ | FILE_SHARE_WRITE and WriteFile function so that i can write the data and CloseHandle after all things are done.
Also, i used a endless looped thread to monitor if there is any data incoming and called ReadFile to read them.
Those pointer(array) type variables are declared as global variable and only initialize at the beginning
int i,j,k;
unsigned char csum = 0;
DWORD NumberOfBytesRead = 0;
int retry = 0;
DWORD NumberOfBytesWrite = 0, dwWaitResult;
HANDLE hKR = INVALID_HANDLE_VALUE;
As i know these variables will be automatically free/deleted after the function ended.
This program is run for a day in Windows XP. Data keep sending and reading for every 2 seconds without any error. From the task manager, i noticed that memory usage of my program is increased by 4KB. This is the first problem i can't deal with because i think i free all used memory except the global variables (buffer for read and write, one time initialized).
To do a deeper research, i downloaded a program called "Process Heap Viewer" to try to see if any block increased when the memory usage is increased. Amazing thing happened, the memory usage is decreased by 2,xxx KB (originally 4,456 KB). I am now totally confused with all the things happened. Could anyone help me for this? Sorry for the long text and poor English :(
Thanks
Danny