First of all thank you very much for your help

We have downloaded drools-5.5.x source code and tried your patch and we have noticed:
- When our resources (guvnor) are not accessible KnowledgeAgent does not rebuild kbase
- When our resources (guvnor) are accessible and we made some change then KnowledgeAgent rebuild kbase after every loop because guvnor responses LastModified (((HttpURLConnection) conn).getLastModified) as GMT datetime but it is not (it depends of the timezone)

We have done more changes in drools-core.5.5.0.FINAL in the class UrlResource.java version to fix this
    private long grabLastMod() throws IOException {
        // use File if possible, as http rounds milliseconds on some machines, this fine level of granularity is only really an issue for testing
        // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4504473
        if ("file".equals(url.getProtocol())) {
            File file = getFile();
            return file.lastModified();
        }
        URLConnection conn = openURLConnection(getURL());
        if (conn instanceof HttpURLConnection) {
            ((HttpURLConnection) conn).setRequestMethod("HEAD");
        }
.......
<b>        long date = 0;
        try {
            date = Long.parseLong(conn.getHeaderField("lastModified"));
        } catch (Exception e) { /* well, we tried ... */
        }
        if (date == 0) {
            date = conn.getLastModified();
        }</b>
.......
        return date;
    }


On the other hand if cache file is updated KnowledgeAgent keeps rebuilding kbase, so to fix this we update lastRead variable

public InputStream getInputStream() throws IOException {
        try {
            long lastMod = grabLastMod();
            if (lastMod == 0) {
                //we will try the cache...
                if (cacheFileExists()) {
                    <b>this.lastRead = getCacheFile().lastModified();</b>
                    return fromCache();
                }
            }
......

Finally, all these changes do not solve the problem of memory leak with incremental kbase changes because resource changes generate a kbase rebuilding (guvnor up). This causes a kbase memory increase

        
        
        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://drools.46999.n3.nabble.com/KnowledgeAgentImpl-memory-leak-5-5-0-Final-tp4028798p4028932.html">Re: [rules-users] KnowledgeAgentImpl memory leak (5.5.0.Final)</a><br/>
Sent from the <a href="http://drools.46999.n3.nabble.com/Drools-User-forum-f47000.html">Drools: User forum mailing list archive</a> at Nabble.com.<br/>