Reason and solution of "*** Error in `python': free(): corrupted unsorted chunks: 0x0000000000ff2460 ***" in Python
<p>i create a service on Python, who connects to sql Azure using pymssql and only makes a select querys, and after 1 day (or a bit more), the connection begins to fail in querys and finally the service ends with the error <strong>* Error in `python': free(): corrupted unsorted chunks: 0x0000000000ff2460 *</strong>, i don't be sure if are one error or more (maybe the first error provoques more errors).</p>

<p>the code of connection is here:</p>

<pre><code>  connectionDb = pymssql.connect(host=self.HOST_DATA_BASE, user=self.USER_DATA_BASE, password=self.PASSWORD_DATA_BASE, database=self.DATA_BASE_NAME)    
</code></pre>

<p>and i execute the query in the next form:</p>

<pre><code>  cursor=connectionDb.cursor()
  cursor.execute("select * from vehicles") 
  rows = cursor.fetchall()

  if (rows!=None):
     return rows
</code></pre>

<p>And initially, the connection is ok, and works fine, the problem is after a time of inactivity.</p>

<p>I try to simplify the querys but i donÂ´t belive that is the reason of error.</p>

<p>*Maybe is posible a bug of pymssql?</p>

<p>@APRocha, It seems to be not a bug of pymssql, it's an error from glibc when python free some malloc memory. </p>

<p>Did you close the connection after done the sql opertion per request? If not, I suggest you do, or using SQLAlchemy with pymssql to manage the connections in a pool.</p>

<p>Otherwise, I think you can try to use <code>gc.collect()</code> to release the unreferenced memory at intervals, please refer to the <a href="https://docs.python.org/3/library/gc.html" rel="nofollow">document</a> as reference.</p>

<p>Hope it helps.</p>

python sql azure