Results 1 to 5 of 5

Thread: Question regarding CreateObject

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89

    Angry

    I was having a discussion with my friends regarding this. From what i comprehend, when we write the code as

    set obj= server.createobject("CDONTS.NewMail")

    A new object(all the classes and properties in it) will be created every each time. But my friend think that if the statement has been used during application on start, this will only create a reference to the class of the object with another new layer consisting the data. Which of this is true or neither is true??

    And what would happen if we don't set the object = nothing after we have us the object?? Will it be demolish after a certain period of time or just reside in the memory??

    Somebody please help to answer this. Thanks.

  2. #2
    Fanatic Member Ianpbaker's Avatar
    Join Date
    Mar 2000
    Location
    Hastings
    Posts
    696

    Smile

    Hello Iychew

    As To the Set Object to nothing You are Correct.

    If You Don't set it to nothing it will still stay In memory And will cause Problems If your site gets Hit enough.

    As For your other problem as far as I know it creates A new instance each time.

    Hope this helps

    Ian

    [Edited by Ianpbaker on 04-25-2000 at 10:46 AM]

  3. #3
    Frenzied Member HarryW's Avatar
    Join Date
    Jan 2000
    Location
    Heiho no michi
    Posts
    1,827
    I don't know for sure, but I reckon you're right, you get a new object every time. I think if you equate one instance of the class to another, like
    Code:
    objObject1 = objObject2
    then it will do like your friend says, make objObject1 a reference to objObject2, since you can't copy objects like user-defined types. If you're just instantiating a new object of the same class then I would have thought you got a new, seperate object.
    Harry.

    "From one thing, know ten thousand things."

  4. #4
    New Member
    Join Date
    Jan 2000
    Location
    Netherlands
    Posts
    5

    Post Playing with objects...

    Greetings,

    If in Application_OnStart an object is set, it will be reset when a page sets that same object. It will first be terminated, then it will be initialised.

    If the object variable is declared in the page, setting it will make a new object for every page. It will remain in memory until the visitor during whoms visit the object is created quits. Quitting is done by timing out or using the abandon method.

    If the object variable is declared in global.asa, setting it will reinitialise that variable. If the object's scope is session, there will be a new object for every session. If the scope is application, there will be only one object for every user. Setting it in the page then most likely leads to errors for other users.

    If you don't set an object to nothing, it will reside in memory until the session or application quits. This could lead to memory hogs. COULD. Might not. Depends on you. If you don't use sessions nor a global.asa, objects reside in memory as long as the page is wanted (or in server cache). Effectively the object is killed on time-out.

    Setting to nothing affects the object where it is declared. Setting application-scope objects to nothing renders them inaccessible to all users. Setting session-scope objects to nothing renders them useless to one user for the rest of the session (should be reaccessible, is not). Setting page objects to nothing clears up memory for that page.

    Hope this helps.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Aug 1999
    Posts
    89
    Thanks guys...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width