How Far Should You Go To Use Valgrind?

This is a discussion on How Far Should You Go To Use Valgrind? within the C++ Programming forums, part of the General Programming Boards category; Originally Posted by steals10304 I'm running windows. It looks like Valgrind is for a linux box. Also, I'm a student ...

  1. #1
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875

    How Far Should You Go To Use Valgrind?

    Quote Originally Posted by steals10304 View Post
    I'm running windows. It looks like Valgrind is for a linux box. Also, I'm a student and don't want to buy anything.
    Then reformat your Windows box to Linux and install Valgrind and many more tools for free...

    Moderator Note: This thread was split from Will my memory leak? --school project so that the participants can settle this important question of going the distance to use Valgrind, without derailing that thread.
    Last edited by laserlight; 02-23-2010 at 12:38 PM.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,165
    Quote Originally Posted by jeffcobb View Post
    Then reformat your Windows box to Linux and install Valgrind and many more tools for free...
    What kind of advice is that!?! How about just throwing out the computer out the window? That will solve all problems.

    Anyway, another good idea is to use smart pointers. They will alleviate the memory issues, if you are allowed to use them. They exist in TR1: std::tr1::shared_ptr and boost: boost::shared_ptr.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  3. #3
    Dae
    Dae is offline
    Deprecated Dae's Avatar
    Join Date
    Oct 2004
    Location
    Canada
    Posts
    1,034
    Quote Originally Posted by Elysia View Post
    What kind of advice is that!?! How about just throwing out the computer out the window? That will solve all problems.
    Hahahaha, wow, leave it to a Windows fanatic to make a comparison like that.

    Virtual Windows (VirtualBox, VMWare) runs faster on Linux.

    I would at least try running virtual Linux, but it runs slower on Windows.

    Dualboxing is common but a hassle. What I like to do is have a Linux box beside me, SSH server running, pop it on a drive letter (ExpanDrive) and SSH in.

    The only reason I run Windows is for 3D games. For shame companies developing exclusively for Windows.
    Warning: Have doubt in anything I post.

    GCC 4.5, Boost 1.40, Code::Blocks 8.02, Ubuntu 9.10 010001000110000101100101

  4. #4
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Quote Originally Posted by Elysia View Post
    What kind of advice is that!?! How about just throwing out the computer out the window? That will solve all problems.

    Anyway, another good idea is to use smart pointers. They will alleviate the memory issues, if you are allowed to use them. They exist in TR1: std::tr1::shared_ptr and boost: boost::shared_ptr.
    It was said in jest after a fashion but in truth it was a solution (student needs debugger, has no money, this was a no-cost solution to all of that) and frankly I saw it not as throwing the computer away but rather more of an upgrade if you will...I am sorry that Windows dev tools cost so much; I think its insane...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  5. #5
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,165
    Quote Originally Posted by Dae View Post
    Hahahaha, wow, leave it to a Windows fanatic to make a comparison like that.

    Virtual Windows (VirtualBox, VMWare) runs faster on Linux.

    I would at least try running virtual Linux, but it runs slower on Windows.

    Dualboxing is common but a hassle. What I like to do is have a Linux box beside me, SSH server running, pop it on a drive letter (ExpanDrive) and SSH in.

    The only reason I run Windows is for 3D games. For shame companies developing exclusively for Windows.
    You are missing the point.
    The thing is that Linux is NOT Windows. Therefore, telling people to "upgrade" to Linux would be like saying, stop eating apples and start eating oranges.
    Hence the analogy of throwing out the computer out the window.
    You may run Linux, but that doesn't mean others should or will. Telling people to drop whatever they use and use Linux or Windows is a stupid, pointless comment.
    Linux isn't better than Windows and Windows isn't better than Linux. You choose an operating system depending on your needs and your preferences.

    Quote Originally Posted by jeffcobb View Post
    It was said in jest after a fashion but in truth it was a solution (student needs debugger, has no money, this was a no-cost solution to all of that) and frankly I saw it not as throwing the computer away but rather more of an upgrade if you will...I am sorry that Windows dev tools cost so much; I think its insane...
    A poor solution. A very poor solution.
    You may see it as an upgrade, but that is YOU. Linux is NOT better than Windows or vice versa, as I already stated. It's like stopping to use a spoon for your supper and instead using a fork. It's a change of life style.
    And the thing that no dev tools exist on Windows or that they aren't free is a myth. There is Visual Studio Express which is free, which includes an IDE, a debugger and compiler. There is Code::Blocks, which is also free, and so on.
    It was a very short-sighted solution.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  6. #6
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Only you would see it as a change of life-style. I have tried to use those "free" versions of Visual Studio for serious work and in every case had to wind up going with at least the "standard" or "pro" versions to do anything aside from toy projects for work. The free edition was (as of 2008 anyways) only a step above shareware...Code::Blocks on Windows is a better solution there, I agree but how many shops use Code::Blocks in the work-place? As for the debugger, Valgrind is in the same league as stuff like Bounds Checker (which is exactly what the OP needs in this case). The debuggers in VS free edition or Code::Blocks are not even close. The OP stressed he/she has no money, is a poor (financially) student and I offered a no-cost way to get higher-end tools. The only other way he/she will get these tools is by hitting the pirate boards or something...so relax. However this is not going to turn into a holy-war or anything so we can just agree to disagree and let the OP find the solution that works best for him/her.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  7. #7
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,165
    Quote Originally Posted by jeffcobb View Post
    Only you would see it as a change of life-style. I have tried to use those "free" versions of Visual Studio for serious work and in every case had to wind up going with at least the "standard" or "pro" versions to do anything aside from toy projects for work. The free edition was (as of 2008 anyways) only a step above shareware...
    Perhaps you can elaborate on why, that the OP and I gain some insight on why it's so bad.

    Code::Blocks on Windows is a better solution there, I agree but how many shops use Code::Blocks in the work-place? As for the debugger, Valgrind is in the same league as stuff like Bounds Checker (which is exactly what the OP needs in this case). The debuggers in VS free edition or Code::Blocks are not even close.
    What? You need to be way more specific here.
    The VS debugger is incredibly powerful and resourceful.
    The VS debugger does have bounds checker, in a way. It will notice if you trash the stack. Furthermore, it does support data breakpoints, so you can set those at the end of your buffers to catch those errors when working with heaps.
    And to make matters even better, one can use std::tr1::array or boost::array for fixed-size arrays. It will assert if you do out-of-bounds. As will std::vector in the Visual Studio debugger!
    I can honestly say I've never had any trouble with it, nor needed much else.
    And there is no change in the free and paid versions of the debugger. You get it all in the free version.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  8. #8
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Hey I tried to end this, someone else split this off...and Elysia the free version was missing some libraries and tools as I recall...it was a year ago and I would have to look up what I was working on at the time. If the debugger in VS is now as powerful as something that does memory profiling and such then I apologize...as of 2008 it was the same old debugger and not in the same class/as comprehensive as Bounds Checker, Insure++ etc.

    For the cost of a download and a little time and learning (and what are students in school to do anyways) the OP could install VirtualBox w/any Linux and get Valgrind for free and automatically find memory leaks/corruption, etc. You can set data break-points, etc with any debugger; with this class of tool you simply run the app and read the report. It doesn't get any simpler than that...
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  9. #9
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    And before the myth about the free edition runs any more rampant here is the truth straight from the horses mouth. Notice the missing higher-end debugging tools for the ADD folks:
    Visual Studio Product Comparison
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  10. #10
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elysia View Post
    And to make matters even better, one can use std::tr1::array or boost::array for fixed-size arrays. It will assert if you do out-of-bounds. As will std::vector in the Visual Studio debugger!
    I wouldn't tell someone to get a linux install just to use valgrind, but this is kind of a version of the same principle (compensate by compromise).

    Or another version: you won't need any of it if you don't write leaks into your code, silly.

    I guess these are all alternatives (personally, I prefer the last one ).

    [Kind of strange there isn't a valgrind for windows, actually, there is a Mac version.]
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  11. #11
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,165
    Quote Originally Posted by jeffcobb View Post
    Hey I tried to end this, someone else split this off...
    I persued the matter in order to give more insight to the OP. The way, he/she can better choose his/her tools.

    ...and Elysia the free version was missing some libraries and tools as I recall...it was a year ago and I would have to look up what I was working on at the time. If the debugger in VS is now as powerful as something that does memory profiling and such then I apologize...as of 2008 it was the same old debugger and not in the same class/as comprehensive as Bounds Checker, Insure++ etc.
    You need to specify what features you want that it's missing!
    How am I--or anyone else for that matter--supposed to make a comparison between Valgrind and the Visual Studio debugger if you don't specify why you predicate Valgrind over VS?

    For the cost of a download and a little time and learning (and what are students in school to do anyways) the OP could install VirtualBox w/any Linux and get Valgrind for free and automatically find memory leaks/corruption, etc. You can set data break-points, etc with any debugger; with this class of tool you simply run the app and read the report. It doesn't get any simpler than that...
    But that was not what you suggested. That's less radical than dumping Windows and installing Linux, which is a really bad suggestion.
    Certainly, that might be an alternative.

    Quote Originally Posted by jeffcobb View Post
    And before the myth about the free edition runs any more rampant here is the truth straight from the horses mouth. Notice the missing higher-end debugging tools for the ADD folks:
    Visual Studio Product Comparison
    I don't see what features you are looking for that are missing. Unfortunately, the free version isn't in there, either. But the only difference in the debug toolset is that some of the higher versions have remote debugging.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.
    For information on how to enable C++11 on your compiler, look here.
    よく聞くがいい!私は天才だからね! ^_^

  12. #12
    spurious conceit MK27's Avatar
    Join Date
    Jul 2008
    Location
    segmentation fault
    Posts
    8,300
    Quote Originally Posted by Elysia View Post
    I don't see what features you are looking for that are missing. Unfortunately, the free version isn't in there, either. But the only difference in the debug toolset is that some of the higher versions have remote debugging.
    Looks to me like memory profiling is not available in any version, period.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main() {
    	char *ptr = malloc(13666);
    
    	return 0;
    }
    valgrind --leak-check=yes ./that_executable

    ==2873== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
    ==2873== malloc/free: in use at exit: 13,666 bytes in 1 blocks.
    ==2873== malloc/free: 1 allocs, 0 frees, 13,666 bytes allocated.
    ==2873== For counts of detected errors, rerun with: -v
    ==2873== searching for pointers to 1 not-freed blocks.
    ==2873== checked 65,040 bytes.
    ==2873==
    ==2873== 13,666 bytes in 1 blocks are definitely lost in loss record 1 of 1
    ==2873== at 0x4C2639E: malloc (vg_replace_malloc.c:207)
    ==2873== by 0x4004DD: main (in /media/sda6/root/C/a.out)
    ==2873==
    ==2873== LEAK SUMMARY:
    ==2873== definitely lost: 13,666 bytes in 1 blocks.
    ==2873== possibly lost: 0 bytes in 0 blocks.
    ==2873== still reachable: 0 bytes in 0 blocks.
    ==2873== suppressed: 0 bytes in 0 blocks.
    C programming resources:
    GNU C Function and Macro Index -- glibc reference manual
    The C Book -- nice online learner guide
    Current ISO draft standard
    CCAN -- new CPAN like open source library repository
    3 (different) GNU debugger tutorials: #1 -- #2 -- #3
    cpwiki -- our wiki on sourceforge

  13. #13
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Quote Originally Posted by Elysia View Post

    I don't see what features you are looking for that are missing. Unfortunately, the free version isn't in there, either. But the only difference in the debug toolset is that some of the higher versions have remote debugging.
    ..and static analysis and code coverage and code profiling and ...

    But you are right: the free edition is not listed here but since these are the paid-for editions you can count on the free edition having even less and the user has to pony up 300 bones just to get the minimum functionality listed here...

    As for the rest of your remarks waaay back I said the "reformat" comment was in jest...I know no Windows programmer is going to use another environment to get better tools for free...how else are they going to play Warcraft and other games?
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  14. #14
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    Oh and if I remember correctly I needed to do 64-bit development for a CAD company to support their 64-bit product. It was *possible* but not made easy by the crippled express edition....

    Edit: now that I look back at it, you did not get MFC or ATL either...
    Last edited by jeffcobb; 02-23-2010 at 02:33 PM.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  15. #15
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    478
    Quote Originally Posted by MK27 View Post
    Looks to me like memory profiling is not available in any version, period.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main() {
    	char *ptr = malloc(13666);
    
    	return 0;
    }
    valgrind --leak-check=yes ./that_executable

    ==2873== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 4 from 1)
    ==2873== malloc/free: in use at exit: 13,666 bytes in 1 blocks.
    ==2873== malloc/free: 1 allocs, 0 frees, 13,666 bytes allocated.
    ==2873== For counts of detected errors, rerun with: -v
    ==2873== searching for pointers to 1 not-freed blocks.
    ==2873== checked 65,040 bytes.
    ==2873==
    ==2873== 13,666 bytes in 1 blocks are definitely lost in loss record 1 of 1
    ==2873== at 0x4C2639E: malloc (vg_replace_malloc.c:207)
    ==2873== by 0x4004DD: main (in /media/sda6/root/C/a.out)
    ==2873==
    ==2873== LEAK SUMMARY:
    ==2873== definitely lost: 13,666 bytes in 1 blocks.
    ==2873== possibly lost: 0 bytes in 0 blocks.
    ==2873== still reachable: 0 bytes in 0 blocks.
    ==2873== suppressed: 0 bytes in 0 blocks.
    Memory Leak Detection Enabling
    "What's up, Doc?"
    "'Up' is a relative concept. It has no intrinsic value."

Page 1 of 3 123 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. erors from Valgrind ,,
    By prakash0104 in forum C Programming
    Replies: 2
    Last Post: 04-05-2009, 07:33 PM
  2. Bug hunting with Valgrind
    By Smjert in forum C Programming
    Replies: 8
    Last Post: 11-06-2008, 03:21 AM
  3. Replies: 1
    Last Post: 12-01-2007, 01:06 AM
  4. Is valgrind always right?
    By g4j31a5 in forum Linux Programming
    Replies: 3
    Last Post: 07-16-2007, 10:39 PM
  5. Valgrind output
    By m_larkin2001 in forum C++ Programming
    Replies: 1
    Last Post: 06-09-2006, 02:28 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21