Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8058373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:20:06+00:00 2026-06-05T09:20:06+00:00

I am using valgrind on a program which runs an infinite loop. As memcheck

  • 0

I am using valgrind on a program which runs an infinite loop.

As memcheck displays the memory leaks after the end of the program, but as my program has infinite loop it will never end.

So is there any way i can forcefully dump the data from valgrind time to time.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T09:20:08+00:00Added an answer on June 5, 2026 at 9:20 am

    Have a look at the client requests feature of memcheck. You can probably use VALGRIND_DO_LEAK_CHECK or similar.

    EDIT:

    In response to the statement above that this doesn’t work. Here is an example program which loops forever:

    #include <valgrind/memcheck.h>
    #include <unistd.h>
    #include <cstdlib>
    
    int main(int argc, char* argv[])
    {
    
      while(true) {
        char* leaked = new char[1];
        VALGRIND_DO_LEAK_CHECK;
        sleep(1);
      }
    
      return EXIT_SUCCESS;
    }
    

    When I run this in valgrind, I get an endless output of new leaks:

    $ valgrind ./a.out
    ==16082== Memcheck, a memory error detector
    ==16082== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
    ==16082== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
    ==16082== Command: ./a.out
    ==16082== 
    ==16082== LEAK SUMMARY:
    ==16082==    definitely lost: 0 bytes in 0 blocks
    ==16082==    indirectly lost: 0 bytes in 0 blocks
    ==16082==      possibly lost: 0 bytes in 0 blocks
    ==16082==    still reachable: 1 bytes in 1 blocks
    ==16082==         suppressed: 0 bytes in 0 blocks
    ==16082== Reachable blocks (those to which a pointer was found) are not shown.
    ==16082== To see them, rerun with: --leak-check=full --show-reachable=yes
    ==16082== 
    ==16082== 1 bytes in 1 blocks are definitely lost in loss record 2 of 2
    ==16082==    at 0x4C2BF77: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==16082==    by 0x4007EE: main (testme.cc:9)
    ==16082== 
    ==16082== LEAK SUMMARY:
    ==16082==    definitely lost: 1 bytes in 1 blocks
    ==16082==    indirectly lost: 0 bytes in 0 blocks
    ==16082==      possibly lost: 0 bytes in 0 blocks
    ==16082==    still reachable: 1 bytes in 1 blocks
    ==16082==         suppressed: 0 bytes in 0 blocks
    ==16082== Reachable blocks (those to which a pointer was found) are not shown.
    ==16082== To see them, rerun with: --leak-check=full --show-reachable=yes
    ==16082== 
    ==16082== 2 bytes in 2 blocks are definitely lost in loss record 2 of 2
    ==16082==    at 0x4C2BF77: operator new[](unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
    ==16082==    by 0x4007EE: main (testme.cc:9)
    ==16082== 
    ==16082== LEAK SUMMARY:
    ==16082==    definitely lost: 2 bytes in 2 blocks
    ==16082==    indirectly lost: 0 bytes in 0 blocks
    ==16082==      possibly lost: 0 bytes in 0 blocks
    ==16082==    still reachable: 1 bytes in 1 blocks
    ==16082==         suppressed: 0 bytes in 0 blocks
    ==16082== Reachable blocks (those to which a pointer was found) are not shown.
    ==16082== To see them, rerun with: --leak-check=full --show-reachable=yes
    

    The program does not terminate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using valgrind to check that my program is within the required memory bounds
I try to track down a memory leak in a c++ program using valgrind.
For memory leaks, there are many tools available such as valgrind, which you can
I am using valgrind to detect memory leaks. the output from valgrind is generated
I have been using valgrind to debug my program (the program functions fine, just
I have a program which accepts 2 N -digit numbers, multiplies them using threads
I am checking my program against memory leaks and corruptions and I have a
I'm trying to use mtrace to detect memory leaks in a fortran program. I'm
I'm trying to use Valgrind on a program that I'm working on, but Valgrind
valgrind-3.6.0.SVN-Debian gcc (Ubuntu/Linaro 4.4.4-14ubuntu5) 4.4.5 2.6.35-22-generic I am using valgrind to detect memory errors

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.