Link to home
Start Free TrialLog in
Avatar of Camillia
CamilliaFlag for United States of America

asked on

(asp.net) un-managed code

I'm working on a asp.net app that's eCommerece. I downloaded a dotnet profiler and ran the app.

The bottleneck shows at an ASHX page and there's a routine in there. It calls database stuff.

But my question is, howcome this is unmanaged code and is unmanaged code bad? ** the profler shows this functon as unmanaged**

This is the code below:


using System;
using System.Web;
using System.Web.UI;
 
using System.Diagnostics;
 
 
using DX.Catalog;
 
 
    public class CategoryUrl : IHttpHandler, System.Web.SessionState.IRequiresSessionState
    {
        public void ProcessRequest(HttpContext context)
        {
            
 
            string destinationPage = "~/ListProdcuts.aspx";
 
   
 
            if (string.IsNullOrEmpty(context.Request.QueryString["Tail"]))
            {
                Category category = Category.GetById(new Guid(context.Request.QueryString["CategoryId"]), true);
                string landingPage = "~/Categs/" + category.TreePath.Replace("/", ".") + ".aspx";
 
                if (System.IO.File.Exists(context.Server.MapPath(landingPage)))
                {
                    destinationPage = landingPage;
                }
            }
 
            context.RewritePath(destinationPage, context.Request.PathInfo, context.Request.Url.Query.TrimStart('?'), false);
 
            IHttpHandler page = PageParser.GetCompiledPageInstance(destinationPage, context.Server.MapPath(destinationPage), context);
            page.ProcessRequest(context);
        }
 
        public bool IsReuse
        {
            get
            {
                return true;
            }
        }
    }

Open in new window

Avatar of raterus
raterus
Flag of United States of America image

Any .Net code you write is managed code, however, you can make calls to unmanaged code.  My guess is some of these methods which you haven't posted more detail on make calls to unmanaged methods, specifically the category object.

Avatar of Camillia

ASKER

ah, so I need to trace that category object? so this ASHX itself is managed but it calls other methods that are unmanaged...

unmanaged code is bad for performance?
ASKER CERTIFIED SOLUTION
Avatar of raterus
raterus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks...makes sense. I will need to look at this bottleneck. Have you used MyGeneration database wrapper...they use it a lot in this app..maybe that's an issue...but good to know I can rule some things out.
Sorry, not familiar with that one :-)
thanks for your help. Will leave this open for now and see if anyone has anything else to add.
You're right , something's going on with that Category object.

Let me ask you this and then I will close question.

The profiler shows that that object consumes 212,206 byes of memory. Total byte allocated for this object is 244,392 bytes That's not good, is it? dont think it is ..
Probably out of my expertise as far as a solid answer, but I do know a program can request a large amount of memory to be reserved for it's execution, memory it may never use.  This might help explain your memory discrepancy.

I really only remember reading this once when I looked up virtual memory, wondering why it's even needed these days.  Seems windows is smart and offloads this reserved memory to a hard-disk until it's actually used in the program.