- Joined
- Sep 26, 2005
- Messages
- 1,088
New sc2 batch shows us that there will be no memory leaks since it will have uber-efficient garbage collector. Your opinions?
Because of all that time and effort that clearing leaks took... oh wait, what time and effort?Dreadnought[dA];1237320 said:more time working on good stuff rather than clearing leaks
I'd rather not trust Blizzard with a garbage collector, so bah.
Because of all that time and effort that clearing leaks took... oh wait, what time and effort?
All it did was force you to think about what you wrote. I'm all for GC, but not for something which likely won't have the bugs ironed out after release.
mystruct *p = new mystruct;
#include <iostream>
using namespace std;
struct node
{
int x;
int y;
};
void MyFunc() {
node n; //The structs and classes in C++ are auto constructed, so declaring
//group g;, it's JASS equivalent to: local group g = CreateGroup().
n.x = 20;
n.y = 10;
cout<<n.x<<" "<<n.y<<endl; //prints both numbers into command pront
}
int main() {
MyFunc();
}
#include <iostream>
using namespace std;
struct node
{
int x;
int y;
};
void MyFunc() {
node *n = new node; //*n means the variable is a pointer
n->x = 20;
n->y = 10;
cout<<n->x<<" "<<n->y<<endl; //prints both numbers into command pront
delete n; //we must delete the memory we allocated.
//n = NULL; //this is unnecessary since n is a local, but if it would be a global, it would need to be nullified.
}
int main() {
MyFunc();
}
Dreadnought[dA];1240073 said:You're probably correct, since when will the code know to get rid of that pointer? Well it still will be nice to not have to:
set a = null
set b = null
set c = null
...I only hope that it wouldn't reset some variables to null without us knowing it.
No point denying it. But hey, why not?Dreadnought[dA];1238443 said:I swear you're just like me, a prick 90% of the time, and yes I know that's not a compliment.
That's a separate issue to do with the fact that the Jass VM apparently doesn't distinguish between locals and globals in most cases, so they are not auto freed at the end of a function (which is required for indexes to be recycled; nothing to do with objects).Dreadnought[dA];1240073 said:You're probably correct, since when will the code know to get rid of that pointer? Well it still will be nice to not have to:
set a = null
set b = null
set c = null