mikeizbicki / ucr-cs100

open source software construction course
Other
486 stars 407 forks source link

HW2: Memory Leak #1547

Closed fvera002 closed 9 years ago

fvera002 commented 9 years ago

How important is memory-leak check for this assignment? The specifications don't say anything about it. So, is it going to affect the grades somehow?

mikeizbicki commented 9 years ago

We will run your program with valgrind, and you cannot have a memory leak. A memory leak will result in -20 pts.

hzhu007 commented 9 years ago

How to know whether I have memory leak? Do we only care about the definitely lost?

hzhu007 commented 9 years ago

In our program every time we call execvp() it will exit. If we allocate memory before it will lost. How can we avoid this problem?

mikeizbicki commented 9 years ago

You only have to care about definitely lost memory.

There is no need to allocate memory on the heap before calling execvp. In fact, there's no need to use the heap in any part of your rshell program. That said, valgrind only tracks the parent process and not the children. (Well, technically you can pass in various flags to get lots of different behaviors, but this is the setup we'd use to test.) So even if you have memory leaks in the children, they wouldn't be detected.