Memory issues EntLib 4.1 - Logging App Block

Topics: Data Access Application Block, Enterprise Library Core, Exception Handling Application Block, Logging Application Block, Policy Injection Application Block
Oct 18, 2010 at 7:21 PM

Hello all!

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:

Exception Handling;
Policy Injection;

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)
manager.Save(matricula); }


For the data access part:

[ExceptionCallHandler("DAL Policy")]
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);



Oct 19, 2010 at 1:38 AM

There were performance problems with the Textformatter in previous versions of EntLib and fix was applied 4.1 which is pretty much like what's discussed in this blog -


Oct 19, 2010 at 9:20 AM

Hello again,


So, if I understand correctly, there is a FIX applied to EntLib 4.1 to resolve the issues described in that blog, right?

Or do I have to search on contrib for the patch and applied it myself? If so, wouldn't I be better off upgrading the all bunch to EntLib 5?

Thanks in a advance & Regards!

Oct 21, 2010 at 3:19 AM

The fix was already applied to EntLib 4.1 so there's no such patch.  If you think performance is still not that good, you can log it in the Issue Tracker.


Sarah Urmeneta
Global Technology & Solutions
Avande, Inc.