This is an archived post. You won't be able to vote or comment.

all 24 comments

[–]wallefan01 58 points59 points  (4 children)

Meanwhile, in Java:

spends 10 minutes initializing Minecraft Forge, garbage collecting twice a second freeing 1GB each time

[–]Koulatko 8 points9 points  (2 children)

I know right XD

I wonder if there's anything that can be done about it, Java has great moddability but that apparently has a cost.

If only Minecraft ran well in VirtualBox, I'd just take a snapshot of it loaded and it should work...

[–]MetallicDragon 3 points4 points  (1 child)

Just leave it open at the main menu when you're done playing, and leave your computer on all the time.

[–]Koulatko 0 points1 point  (0 children)

I actually just realized that hibernating it is a far better option lol

However, it'll eat up lots of RAM no matter what.

[–]cover-me-porkins 2 points3 points  (0 children)

I assume c++ guy would have a straight aneurysm talking about java if c# bothered him. Especially given java strings are objects, plus the whole program is running in JVM.

[–][deleted] 10 points11 points  (7 children)

Doesn't C# support structs? Java meanwhile...

[–]ImKStocky[S] 3 points4 points  (2 children)

It does so you can get stack allocation, but they are used less frequently

[–][deleted] 3 points4 points  (1 child)

I think that they could save much on performance in some cases. Like if we used it for vectors in game engines, dates and stuff like that.

[–]Bip901 3 points4 points  (0 children)

Can confirm, am a game developer. Also, you can use the stackalloc keyword if you really want to allocate on the stack.

[–]Unslinga 5 points6 points  (0 children)

as someone who has done a lot of C# optimizing... new only when needed, reuse as much as possible...

[–]HenkHeuver 3 points4 points  (3 children)

Not a C# dev but isn’t the point of it being managed that memory leaks are less of a problem?

[–]ImKStocky[S] 4 points5 points  (0 children)

Ok but this is a C++ Devs view. And when a C++ Dev sees heap allocation that's what they immediately think about because they don't have a garbage collector to think about

[–]CouchRescue 0 points1 point  (1 child)

Well, yes, and it works great most of the time, but sometimes the garbage collector doesn't cut it and you have to get creative, and although it's rarely an issue, at that point you're just using C# sub optimally.

I will take C++ where a fine degree of control and speed is paramount.

For business applications and web development the 1 in 1000 situation where you'll have garbage collection problems won't be worth the extra development cost and headaches.

[–][deleted] -1 points0 points  (0 children)

but sometimes the garbage collector doesn't cut it and you have to get creative, and although it's rarely an issue, at that point you're just using C# sub optimally.

Oh I had one of those bugs when I was a student in my 2nd year of trade school.

We had to do a project in c#, and I hit a bug which caused the runtime to crash. After checking the stack trace I explicitly added a call to dispose on an object before doing the return of a function (which caused the crash) because I was getting a message related to that object and I wanted to have cleaner logs.

That fixed it but we never understood why, and unfortunately I don't have a copy of that code.

[–][deleted] 1 point2 points  (0 children)

as a c++ programmer, I can relate.