Results 1 to 6 of 6

Thread: .net , collections and memory

  1. #1

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729

    .net , collections and memory

    i have a struct type called SINGLE_ITEM (just for testing) and a collection of it..i add some SINGLE_ITEMS to my arraylist..and then remove some of them..when i remove them from the list i can still access them if i have other references to it? or they get deleted?
    \m/\m/

  2. #2
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Once you remove them from the list I dont think you'll be able to access them again.

  3. #3

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    pseudo code to show a possible situation of what im talkin about:

    dim item as new single_item()
    dim array as new arraylist()
    array.add(item)
    array.delete(item)

    the 'item' is still alive isnt it?
    now if yes as i think it is its ok..but what if its in different subs?
    \m/\m/

  4. #4
    Frenzied Member DevGrp's Avatar
    Join Date
    Nov 2001
    Location
    Charlotte, NC
    Posts
    1,256
    Ok, in that case item is still accessable. Its just not in the collection any more.

  5. #5

    Thread Starter
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    hmm yes but for example in this case?
    Code:
    IrcUser _tmpUser = ((IrcChannel)_channels[command[2]]).Users[nick];
    ((IrcChannel)_channels[command[2]]).Users.Remove(nick);
    if (UserLeftChannel != null) { UserLeftChannel((IrcChannel)_channels[command2], _tmpUser);
    (sorry for being in C#)
    \m/\m/

  6. #6
    Fanatic Member
    Join Date
    Jun 2001
    Posts
    521
    It should still be accessible -- all of its "roots" aren't gone, and therefore it is not garbage. However, the Remove() function might perform some cleanup on the item that is removed that makes it useless.

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