Discussion:
valgrind
(too old to reply)
DHZL
2011-10-12 04:19:44 UTC
Permalink
Will valgrind be used against our code or do the autotests just check
cout?

I guess I'm just wondering do we have to free everything right before
the program exits.
cs240
2011-10-12 05:15:34 UTC
Permalink
It is always a good practise to free any memory that your program uses
before it exits.

Remember that besides auto-testing, your code will also be marked by TAs
for style, documentation, efficiency and etc.

Vivian
cs240 Tutor
Post by DHZL
Will valgrind be used against our code or do the autotests just check
cout?
I guess I'm just wondering do we have to free everything right before
the program exits.
kun qian
2011-10-12 05:31:27 UTC
Permalink
Post by cs240
It is always a good practise to free any memory that your program uses
before it exits.
Remember that besides auto-testing, your code will also be marked by TAs
for style, documentation, efficiency and etc.
Vivian
cs240 Tutor
Post by DHZL
Will valgrind be used against our code or do the autotests just check
cout?
I guess I'm just wondering do we have to free everything right before
the program exits.
The design of this program doesn't allow for checking memory leak very
well :( Since I have two constructor, one that uses memory and one
that doesn't. It makes it hard to know when to delete array or when
not to.
cs240
2011-10-12 08:48:25 UTC
Permalink
I don't think it's hard - you can check whether the memory is allocated
with a simple if statement. If you don't know how to, you should probably
review your CS246 notes first.

Vivian
CS240 Tutor
Post by kun qian
Post by cs240
It is always a good practise to free any memory that your program uses
before it exits.
Remember that besides auto-testing, your code will also be marked by TAs
for style, documentation, efficiency and etc.
Vivian
cs240 Tutor
Post by DHZL
Will valgrind be used against our code or do the autotests just check
cout?
I guess I'm just wondering do we have to free everything right before
the program exits.
The design of this program doesn't allow for checking memory leak very
well :( Since I have two constructor, one that uses memory and one
that doesn't. It makes it hard to know when to delete array or when
not to.
kun qian
2011-10-12 19:48:51 UTC
Permalink
Post by cs240
I don't think it's hard - you can check whether the memory is allocated
with a simple if statement. If you don't know how to, you should probably
review your CS246 notes first.
Vivian
CS240 Tutor
Post by kun qian
Post by cs240
It is always a good practise to free any memory that your program uses
before it exits.
Remember that besides auto-testing, your code will also be marked by TAs
for style, documentation, efficiency and etc.
Vivian
cs240 Tutor
Post by DHZL
Will valgrind be used against our code or do the autotests just check
cout?
I guess I'm just wondering do we have to free everything right before
the program exits.
The design of this program doesn't allow for checking memory leak very
well :( Since I have two constructor, one that uses memory and one
that doesn't. It makes it hard to know when to delete array or when
not to.
Of course you can check it, there are instance where design like this
is very very flaw and a flag simply doesn't solve the problem in the
long run. it's just a quick hack.
DHZL
2011-10-12 20:00:47 UTC
Permalink
Post by kun qian
Post by cs240
I don't think it's hard - you can check whether the memory is allocated
with a simple if statement. If you don't know how to, you should probably
review your CS246 notes first.
Vivian
CS240 Tutor
Post by kun qian
Post by cs240
It is always a good practise to free any memory that your program uses
before it exits.
Remember that besides auto-testing, your code will also be marked by TAs
for style, documentation, efficiency and etc.
Vivian
cs240 Tutor
Post by DHZL
Will valgrind be used against our code or do the autotests just check
cout?
I guess I'm just wondering do we have to free everything right before
the program exits.
The design of this program doesn't allow for checking memory leak very
well :( Since I have two constructor, one that uses memory and one
that doesn't. It makes it hard to know when to delete array or when
not to.
Of course you can check it, there are instance where design like this
is very very flaw and a flag simply doesn't solve the problem in the
long run. it's just a quick hack.
Ok for me it was easy, because like Su Zhang mentioned, both
constructors allocate memory so cleaning in the destructor works the
same for both constructors
kun qian
2011-10-12 20:44:04 UTC
Permalink
Post by DHZL
Post by kun qian
Post by cs240
I don't think it's hard - you can check whether the memory is allocated
with a simple if statement. If you don't know how to, you should probably
review your CS246 notes first.
Vivian
CS240 Tutor
Post by kun qian
Post by cs240
It is always a good practise to free any memory that your program uses
before it exits.
Remember that besides auto-testing, your code will also be marked by TAs
for style, documentation, efficiency and etc.
Vivian
cs240 Tutor
Post by DHZL
Will valgrind be used against our code or do the autotests just check
cout?
I guess I'm just wondering do we have to free everything right before
the program exits.
The design of this program doesn't allow for checking memory leak very
well :( Since I have two constructor, one that uses memory and one
that doesn't. It makes it hard to know when to delete array or when
not to.
Of course you can check it, there are instance where design like this
is very very flaw and a flag simply doesn't solve the problem in the
long run. it's just a quick hack.
Ok for me it was easy, because like Su Zhang mentioned, both
constructors allocate memory so cleaning in the destructor works the
same for both constructors
I suspect they will take marks off if you don't follow their design.
Su Zhang
2011-10-12 14:14:48 UTC
Permalink
Post by kun qian
well :( Since I have two constructor, one that uses memory and one
that doesn't.
Both constructors should allocate memory.
Loading...