9

mini rant

So I finally started toying around C#.

As much as I tried to avoid it, as much as I wanted, well, sometimes there is need. I was laying it off and laying it off...

There are some things that well.. aren't my taste but whatever.

But come on why the fuck I cannot delete explicitly?

What do you mean "just assign it to null and GC will eventually kill off that instance"

No, I want that fucker to die here and right now. Like in good ol' C++.

Comments
  • 5
    Because memory safety and because garbage collectors are faster than ref counting. That's why you can't delete it
  • 0
    @12bitfloat

    yeah, memory safety, sure but if handled properly you wont have problems with it anyway.

    And language itself has excception that can handle it regardless (object reference is not set to instance of object) if I understand it correctly?
  • 1
    I read a few months ago that microsoft wanted to somehow garbage collect objects in vc++. Not sure if its true but rip if it is.
  • 2
    @12bitfloat relying onto your gc too much can end deadly in some cases.
  • 0
    @b3b3 what the fuck?

    Seriously?

    O,,O

    Well, vc++ is no longer c++ it seems.
  • 1
    @DubbaThony can't find the article anymore so I guess it was pure trashtalk from my side.
  • 2
    The “using” keyword is your best bet for deleting.
  • 0
  • 2
    @DubbaThony https://docs.microsoft.com/en-us/...

    using blocks are basically deletes with curly braces.
  • 1
    @bkwilliams but it requires creating instance next to it, i have array of references and want to purge some of objects I no longer need. Oh, did I mention its unity?

    So im unsure if it's revelant, anyway maybe Im nitpicking some of this doc and its not working for me.

    Anyway, thanks, that may come in handy.
  • 1
    @bkwilliams Using (or as Java calls it "try-with-resources") only helps with closing the resource by literally calling the close() method. It doesn't delete the object
  • 2
    The cries of those who despise manual memory management drown out the cries of those who desire it
  • 1
    @AlgoRythm ;(

    I found Destroy() in unity docs...

    I don't know how it works internally but at least **seems** to work maybe? No idea. Seems to work.
  • 1
    @DubbaThony It "deletes" the GameObjects but doesn't delete the actual allocated objects. There's no way around waiting for the next GC.
    You should really worry less about objects. Garbage collectors are specifically designed to deal with this sorta stuff. Even heap allocating temp objects like Vectors isn't fatal because all modern GC's are tiered
  • 1
    @DubbaThony If you're really that concerned with getting every last ounce of performance you really shouldn't be using Unity and instead roll your own engine. That's an immense amount of work though
  • 0
    Why WOULD you want to do it manually ?
    You have using/dispose if you relly really want it.
    You can force GC to collect (Bad practice)
  • 1
    Just let GC to deal with it
    https://youtu.be/d-diB65scQU
  • 0
    @NoToJavaScript

    Bad practice? Maybe but Im manual memory managment team.
  • 0
    If you are so inclined to do it, just close them and call GC.
    If you wanted memory management so bad you should use a language that allows it.
  • 2
    Im with you on this one, GC is an extra layer of unecessary processing when you know what you're doing. I don't want anything more than for GC to be there, but still give me control over the memory efficiently. But alas, get used to GC's... Its not going away no matter how it hurts
  • 0
    @kurast

    Can you do so in unity?

    Only engine I know that allows so is unreal aaaand kindda nah for me. Dont get me wrong, i like c++ but i am aware c++ is slower to write in for me even if I really really enjoy it (yeah and I enjoy debugging, dont question it, okay?)
  • 0
    @DubbaThony Now ask yourself the question: "Why is it slower to write in C++?"
  • 0
    @12bitfloat

    Templates?
    Less "standard high level" operations and more Wacky::<Syntax>("that I hate so much")

    Managing memory is actually one of things I dont find bottlenecking me
Add Comment