How to release memory of mysql connection open when working on c# -
mysqlconnection con = null; con = new mysqlconnection(); con.connectionstring = @"connection_string"; mysqlcommand cmd = new mysqlcommand(); cmd.connection = con; try { con.open(); //its increasing memory size 4 mb ///--------------------------logic----------------------// ///------------------------------------------------------// con.close(); //it not work : memory not reallocate. } catch { }
try use try - final block , close connections / commands on final block or use using statement
use connection pool, connections re-used , amount of memory won't go higher amount.
what observe here (not clearing memory when close connection), because if close connection gc won't collecting effective immediately, , won't trigger until application maxed out stack
Comments
Post a Comment