This is my first post here, so I'll try not to be much of a "pain".
I'm having some trouble to understand some issues on my application (windows forms), and I'm hopping to get some help here. This is my scenario:
Enterprise Library with following application blocks configured:
I use policy injection to take care o exception handling. Exception handling is configured to use logging.
The thing is that I'm having huge memory consumption on my app, specially when It does repetitive tasks (cycles). I have 3 "layers" (data access, business, gui).
After some profiling, I noticed that there are always an enormous amount of string objects being allocated and never released. After some more digging, I found that the majority of those strings, are beeing held by Enterprise Library Logging Application
Block objects, mainly Formatters.
The process profiled does the following:
1. Cycle through a list of people;
2. For each people there's some calculations being done;
3. For each people there is an insert into the database;
I "suspect" that at each iteration of the cycle, the EntLib configuration is being put into memory, despite all the calls are enclosed in "using" statements.
Any help would be very much appreciated!
the code is something like this (very, very trimmed down) for the GUI part:
foreach(ObjStudent student in Students)
private void PrepareMatriculas(ObjStudent student)
student.Name = "Name";
// Doing more stuff like this and some calculations
For the Business part, it's like this:
List<ObjMatriculas> matriculas = new List<ObjMatriculas>();
foreach (ObjStudent student in students)
ObjMatricula matricula = new ObjMatricula()
ID_Curso = student.ID_Curso,
DataMatricula = Sistema.BLL.ServicoTabelasBaseSistema.GetData().Date,
DataSituacao = Sistema.BLL.ServicoTabelasBaseSistema.GetData().Date,
ID_NUtente = student.ID_NUtente,
ID_SituacaoFinal = 1, // matriculado
IsPrematricula = student.IsPrematricula,
Nome = student.Nome
OnNotifyProgresso(1, "Doing Stuff");
using(StudentsDataManager manager = PolicyInjection.Create<StudentsDataManager>())
foreach (ObjMatricula matricula in matriculasNovas)
For the data access part:
public void SaveBloco(Base.BusinessObject busObj)
Database dbMatriculas = new SqlDatabase(QS.PAAE.Sistema.CONFIG.Configuracoes.ConnectionString);
using (DbConnection cnMatriculas = dbMatriculas.CreateConnection())
using (DbTransaction trnMatriculas = cnMatriculas.BeginTransaction())
using (DbCommand cmdMatricula = dbMatriculas.GetStoredProcCommand("PED_MatriculasInsProc"))
// Parameters go here
id_Matricula = (int)dbMatriculas.ExecuteScalar(cmdMatricula, trnMatriculas);