nikhilgupta10 / GridLAB-D

Other
1 stars 0 forks source link

#935 server mode memory leak, #2661

Open nikhilgupta10 opened 7 years ago

nikhilgupta10 commented 7 years ago

Memory leak was found in server code. Easily confirmed by doing repeated reads of the same variable in server mode. Fix proposed on https://github.com/sk4ld/gridpot/commit/ce7eec40b9d1c4474e7659b32929526c0500e4f1 looks good.,

nikhilgupta10 commented 7 years ago

nikhilgupta10 imported these comments from Sourceforge: The user dchassin does not exist anymore. Therefore assigning this to afisher1. "dchassin":The proposed fix does not completely eliminate the memory leak, but it does seem to decrease the rate at which memory is exhausted.,

"dchassin":There is a second memory leak because pthread_detach() does not automatically clean up the HTTP buffers. A new function called http_destroy() has to be added and called by http_close(). The revised core/server.c files I used are attached. The glm file is as follows:

// server memory leak test for ticket 935
#option server
#set run_realtime=1
class test {
    randomvar test;
}

object test {
    test    ype:normal(0,1); refresh:1\;
}

The bash test script is as follows:

#!/bin/bash
# server memory leak test for ticket 935
while true; do
        wget http://localhost:6267/xml/test:0/test -q -O - | grep 'value'
done

The memory leak is confirmed fixed by observing that memory use does not increase as wget calls are completed.

Note: this was completed and tested only on Windows x64. The test script was run from a Linux machine but the hostname has been changed in the post to remove the local IP address I used.,

"dchassin":- labels: --> memory leak, server, pthread_detach, http_destroy