View Full Version : Problem in software engineering exercise
anon10364
13-10-2012, 01:48 AM
Sir,
In software engineering exercise question 5 says to create a target in makefile ,checkmemory and use valgrind+grep to check that memory usage is within a certain limit. Sir in this question can we just use valgrind to solve the question or is it necessary to use grep command.Sir basically i am unable to understand why we have to use grep command with valgrind.
Thanks,
Anon10364
Anon10364,
If you just use valgrind, how will you figure out whether the memory usage was exceeded? The Makefile target will never fail. If this test were to run on 10000 test cases every night and then let us know in the morning if anything failed we will not be able to automate it. You use grep to extract from this valgrind log how much memory was consumed. Next use some (shell) scripting inside the Makefile to check that the usage is definitely below a threshold.
Thanks,
Anup
anon10320
02-12-2012, 07:49 PM
Sir,
I'm using valgrind+grep ./target to checkmemory but it says "command not found" .I'm so confused and what is the intension of changing the name of target in Makefile .
Thanks
anon10320
Anon10320,
There is no command valgrind+grep, I am not sure what you are trying to achieve here. The correct way to use valgrind is valgrind -v <file name> | less
Thanks,
Anup
anon10457
24-02-2013, 02:03 AM
Hi,
Q5 of medium exercise of Software Engineering Aspects the command
valgrind ./bin/checkmemory < test/test.sql | grep usage should not just display the line where so ever the word 'usage' has come from the output.?
Cos it is not doing the same. I've attached its screenshot also.
basant
24-02-2013, 08:20 AM
Anon10457,
Your screenshot clearly shows the memory usage and your command seems to be working fine.
-- Basant
anon10457
24-02-2013, 10:12 AM
Hi,
From
valgrind ./bin/checkmemory < test/test.sql | grep usage it should just display the line
==13698== total heap usage : 401 allocs 186 frees , 73835 bytes allocated
Right? Not the other details with it.
But it does not seems to be happening.
Thanks,
Anon10457
basant
24-02-2013, 11:32 AM
Anon10457,
Now I get your question.
valgrind ./bin/checkmemory < test/test.sql | grep usage
In the above command, grep is working on stdout. However, valgrind is dumping all the information on stderr. That is grep is not working. If you redirect all stderr output also on stdout, then grep will output lines only with "usage" pattern.
So, try the following.
valgrind ./bin/checkmemory < test/test.sql 2>&1 | grep usage
-- Basant