Server.CreateObject Vs CreateObject

Discussion in 'ASP General' started by Sagar, Jan 15, 2008.

  1. Sagar

    Sagar Guest

    I am working on a project where Server.CreateObject is replaced with
    CreateObject all over the project. Though I know that this will
    improve performance in terms of Memory overlhead because of how the
    object creation happens with Server.CreateObject, I would like to
    create 'visible scenarios' that i create with code to show people that
    '"look. here's the difference". Is it possible ?

    I will create a page with 2 calls, 1 with Server.CreateObject and 1
    with CreateObject, run the code and see the difference. Any thoughts ?


    Thanks.
    Anand.
     
    Sagar, Jan 15, 2008
    #1
    1. Advertising

  2. "Sagar" <> wrote in message
    news:...
    > I am working on a project where Server.CreateObject is replaced with
    > CreateObject all over the project. Though I know that this will
    > improve performance in terms of Memory overlhead because of how the
    > object creation happens with Server.CreateObject, I would like to
    > create 'visible scenarios' that i create with code to show people that
    > '"look. here's the difference". Is it possible ?
    >
    > I will create a page with 2 calls, 1 with Server.CreateObject and 1
    > with CreateObject, run the code and see the difference. Any thoughts ?
    >


    I've never heard of any significant memory usage difference between the two
    and I find it difficult to see what might be the cause of such a difference.

    The only real difference between the two is handling of OnStartPage and
    OnEndPage methods on the classes default interface.

    When using Server.CreateObject after the object is instanced ASP looks for
    the OnStartPage method on the returned interface, if found it is called with
    the current script context as a parameter.

    This handling does not occur for CreateObject. However, since IIS 5.0 ASP
    runs as a COM+ context and components can implement IObjectContext through
    which the scripting context can be discovered. This approach works whether
    the Server version is used or not.

    Personally I still implement OnStartPage since its a lot less faff but it
    does require the use of Server.CreateObject.

    --
    Anthony Jones - MVP ASP/ASP.NET
     
    Anthony Jones, Jan 15, 2008
    #2
    1. Advertising

  3. Sagar

    Sagar Guest

    Not really. I have read in other sites that there IS a difference.

    With Server.CreateObject, the object instance is created with the
    context of transaction
    With CreateObject, the obect is created without any context.

    Let me know if this is incorrect.

    and Is there a way to demo these scenarions and some simple code ?

    Thanks,
    Anand.

    On Jan 15, 6:35 pm, "Anthony Jones" <> wrote:
    > "Sagar" <> wrote in message
    >
    > news:...
    >
    > > I am working on a project where Server.CreateObject is replaced with
    > > CreateObject all over the project. Though I know that this will
    > > improve performance in terms of Memory overlhead because of how the
    > > object creation happens with Server.CreateObject, I would like to
    > > create 'visible scenarios' that i create with code to show people that
    > > '"look. here's the difference". Is it possible ?

    >
    > > I will create a page with 2 calls, 1 with Server.CreateObject and 1
    > > with CreateObject, run the code and see the difference. Any thoughts ?

    >
    > I've never heard of any significant memory usage difference between the two
    > and I find it difficult to see what might be the cause of such a difference.
    >
    > The only real difference between the two is handling of OnStartPage and
    > OnEndPage methods on the classes default interface.
    >
    > When using Server.CreateObject after the object is instanced ASP looks for
    > the OnStartPage method on the returned interface, if found it is called with
    > the current script context as a parameter.
    >
    > This handling does not occur for CreateObject.  However, since IIS 5.0 ASP
    > runs as a COM+ context and components can implement IObjectContext through
    > which the scripting context can be discovered.  This approach works whether
    > the Server version is used or not.
    >
    > Personally I still implement OnStartPage since its a lot less faff but it
    > does require the use of Server.CreateObject.
    >
    > --
    > Anthony Jones - MVP ASP/ASP.NET
     
    Sagar, Jan 15, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.

Share This Page