I am running a c program on a CentOS 5.5 computer. The program runs a loop that performs tests over and over until told to stop by an external source.
By necessity I am using an old driver for a PCI card that communicates with my test system. Since upgrading from CentOS 4.5 to 5.5 I have noticed I can only loop through my program 175 times. At that time the program halts with an error allocating heap memory. I can watch the memory being used in chunks of 10 to 20 MB each time the program loops and the system just runs out of memory. When I exit the program using Cntrl-C the memory is immediately freed.
I have used Valgrind which indicates the memory leaks are in the old driver. The company that wrote the driver only supports Windows now and they haven't upgraded the driver in over 5 years.
Without the source code is there any way I can free the memory used by the driver each time I loop through my program?
Thanks.
If you declare the access to the test system through the driver inside the loop, this should put it out of scope on each iteration.
Something like the following:
char readbuf[512];
for (int i = 0; i < countloops; i++)
{
int fd = open("/dev/com1", O_RDWR);
readbuf = read(fd, sizeof (readbuf));
close (fd);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With