I'm not a big fan of posting code, but I'm having a terrible time determining where the memory leak is coming from in this Windows Service that I'm writing. What the service is doing, is pulling a list of records from a database about some images, then goes and does some moving of the images/resizing and gets the info from them (height, width, size, etc.) and puts that data in a different table. However, as the title explains, there's a memory leak somewhere in here and I don't know what else to do. I've tried disposing and getting rid of all the objects I can, but maybe I'm doing it wrong or just missing something. Here's the service code:
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.ServiceProcess; using System.Text; using NHibernate; using NHibernate.Expression; using System.Configuration; using System.IO; using System.Reflection; using System.Drawing; using System.Drawing.Drawing2D; using System.Timers;
namespace RodunuPhlogger { public partial class Service1 : ServiceBase { private static TraceSwitch _DebugLevel = new TraceSwitch("DebugLevel", "The output level of tracing"); private static string logfile; private static ISession m_Session; private static System.Collections.IList aReadyToMove = null; private static Timer phlogTimer = null;
// get height and width of images int mainImageWidth = mainImage.Width; int mainImageHeight = mainImage.Height; int thumbImageWidth = thumbImage.Width; int thumbImageHeight = thumbImage.Height;
// start our first transaction session m_Session = DBHelper.LoadSession(); ITransaction it = m_Session.BeginTransaction();
try { // now we create a new record in the database ModulePhlog mpPhlog = new ModulePhlog();
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
The Grade of the Solution
The Zone Rank of the Expert Providing the Solution
The Number of Author and Expert Comments
The Number of Experts Contributing
The Feedback of the Community
Your Input Matters Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.
If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.