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 8712991
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T05:14:03+00:00 2026-06-13T05:14:03+00:00

I wrote a test C++ program to check the output of valgrind. The code

  • 0

I wrote a test C++ program to check the output of valgrind. The code is

#include <iostream>

void f() {
    int *pp = new int(1);
    std::cout << "pp is " << *pp << "\n";
}

int main() {
    f();
    return 0;
}

The valgrind command I used is

valgrind --leak-check=yes ./a.out

The output from Valgrind is

==2255== HEAP SUMMARY:
==2255==     in use at exit: 4 bytes in 1 blocks
==2255==   total heap usage: 1 allocs, 0 frees, 4 bytes allocated
==2255== 
==2255== 4 bytes in 1 blocks are definitely lost in loss record 1 of 1
==2255==    at 0x4C2B1C7: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==2255==    by 0x400786: f() (in /run/shm/a.out)
==2255==    by 0x4007CC: main (in /run/shm/a.out)
==2255== 
==2255== LEAK SUMMARY:
==2255==    definitely lost: 4 bytes in 1 blocks
==2255==    indirectly lost: 0 bytes in 0 blocks
==2255==      possibly lost: 0 bytes in 0 blocks
==2255==    still reachable: 0 bytes in 0 blocks
==2255==         suppressed: 0 bytes in 0 blocks

I am using a Ubuntu machine:
Linux Sun 3.2.0-27-generic #43-Ubuntu SMP Fri Jul 6 14:25:57 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

gcc version “4.6.3”

gcc parameter I used “-g -m64”

I think it should be eight bytes, right?

  • 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-13T05:14:04+00:00Added an answer on June 13, 2026 at 5:14 am

    No, it shouldn’t be eight bytes unless sizeof(int)==8 on your platform.

    You’re allocating, and leaking, a single int, not a pointer.

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

Sidebar

Related Questions

I wrote a test program to monitor my Picture folder which points to c:\users[username]\Pictures
I wrote a test program thinking that the address of p1 will be less
I wrote a simple test program for opencv to see if it's working after
I wrote a small test program for flipperview. I have 3 views. I call
I wrote a small program to test accessing a widget parent's slot. Basically, it
I wrote a simple program to test a theory that finally block will always
I'm trying to write a program to test student code against a good implementation.
I am new to multithreading, and I wrote this code which prints the numbers
I am trying a reasonably simple program to test binary input/output. I am basically
I wrote a test program wherein a single Button is defined in XAML as

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.