Note that there are some explanatory texts on larger screens.

plurals
  1. POpossible memory leak?
    primarykey
    data
    text
    <p>i'm profiling the below code inside a singltone and found that a lot of Rate objects are kept in memory altough i clear them.</p> <pre><code>protected void FetchingRates() { int count = 0; while (true) { try { if (m_RatesQueue.Count &gt; 0) { List&lt;RateLog&gt; temp = null; lock (m_RatesQueue) { temp = new List&lt;RateLog&gt;(); temp.AddRange(m_RatesQueue); m_RatesQueue.Clear(); } foreach (RateLog item in temp) { m_ConnectionDataAccess.InsertRateLog(item); } temp.Clear(); temp = null; } count++; Thread.Sleep(int.Parse(ConfigurationManager.AppSettings["RatesIntreval"].ToString())); } catch (Exception ex) { } } } </code></pre> <p>the insertion to the queue is made by:</p> <pre><code>public void InsertLogRecord(RateLog msg) { try { if (m_RatesQueue != null) { //lock (((ICollection)m_queue).SyncRoot) lock (m_RatesQueue) { //insert new job to the line and release the thread to continue working. m_RatesQueue.Add(msg); } } } catch (Exception ex) { } } </code></pre> <p>the worker inserts rate log into DB as follows:</p> <pre><code> internal int InsertRateLog(RateLog item) { try { SqlCommand dbc = GetStoredProcCommand("InsertRateMonitoring"); if (dbc == null) return 0; dbc.Parameters.Add(new SqlParameter("@HostName", item.HostName)); dbc.Parameters.Add(new SqlParameter("@RateType", item.RateType)); dbc.Parameters.Add(new SqlParameter("@LastUpdated", item.LastUpdated)); return ExecuteNonQuery(dbc); } catch (Exception ex) { return 0; } } </code></pre> <p>any one sees a possible memory leak? </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload