<div style="font-family: Helvetica; font-size: 13px; ">Not knowing how exactly you set up your interop with mysql, is there any chance your application tries to keep too many mysql connections open? A simple "show processlist;" inside of a mysql console should rule out this possibility.<div><br></div><div>Also, are you reading to or writing from any files at any point independently of the snap infrastructure? I have had issues in the past with intermittent background file reads not being strict enough and eventually starving the system of file descriptors.</div><div><br></div><div>Cheers,</div><div>Ozgun</div></div>
                <div></div>
                 
                <p style="color: #A0A0A8;">On Sunday, January 8, 2012 at 4:27 PM, Gregory Collins wrote:</p>
                <blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
                    <span><div><div><div>On Sun, Jan 8, 2012 at 7:25 AM, Eric Wong <span dir="ltr">&lt;<a href="mailto:wsysdu@gmail.com">wsysdu@gmail.com</a>&gt;</span> wrote:<br><blockquote type="cite"><div>
<div style="word-wrap:break-word">Hi haskellers,<div><br></div><div>I wrote a web server using snap framework. Basically, it's an API server using hdbc-mysql to connect to a mysql server. But it also serves some static web pages and images, using the serveDirectory function in snap-core. The program eats more and more memory slowly, but I couldn't spot the leak. It uses less than 10MB memory when starting. Sometimes, it can grow to 60-70MB and stop working correctly. Then I find that the log file is full of "too many open files" error. As I don't have any code open any files, I suspect it's the serveDirectory leaking. But I don't have any expertise on the core of snap, so, could some one give me some advice on this problem?&nbsp;</div>
</div></div></blockquote></div><div><br></div>I'm fairly certain there's no leak in Snap in this code, although I will gladly accept evidence to the contrary -- I've been load-testing "serveDirectory" at 20,000 qps for a couple of minutes now, with no increase in the memory resident size.<div>
<br></div><div>A "too many open files" error is usually due to running out of file descriptors for network sockets. On my Linux machine the per-process limit for file descriptors defaults to 1024, and on my Mac the default is 256. You can see your current limit by running "ulimit -a" from the terminal.<div>
<br></div><div>Each incoming socket occupies a file descriptor, as does every open connection to your database and every open file. When these run out, calls to accept() or to open files start failing and you get this error message.</div>
<div><br></div><div>Memory profiling should help you find the leak.</div><div><br></div><div>G<br clear="all"><div>--&nbsp;</div>Gregory Collins &lt;<a href="mailto:greg@gregorycollins.net" target="_blank">greg@gregorycollins.net</a>&gt;<br>

</div></div>
</div><div><div>_______________________________________________</div><div>Haskell-Cafe mailing list</div><div><a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a></div><div><a href="http://www.haskell.org/mailman/listinfo/haskell-cafe">http://www.haskell.org/mailman/listinfo/haskell-cafe</a></div></div></div></span>
                 
                 
                 
                 
                </blockquote>
                 
                <div>
                    <br>
                </div>