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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:43:41+00:00 2026-06-06T13:43:41+00:00

Consider this small program: #include <stdio.h> #include <stdlib.h> // Change 60000 to 70000 and

  • 0

Consider this small program:

#include <stdio.h>
#include <stdlib.h>

// Change 60000 to 70000 and valgrind (memcheck) eats my memory
#define L (60000)
#define M (100*(1<<20))

int main(void) {
  int i;
  for (i = 0; i < M; ++i) {
    unsigned char *a = malloc(L);
    a[i % L] = i % 128; // Touch something; a[0] is not enough
    free(a);
    if (i % (1<<16) == 0)
      fprintf(stderr, "i = %d\n", i);
  }
  return 0;
}

Compiling with gcc -o vg and running valgrind --leak-check=full ./vg works fine, with memcheck using roughly 1.5% of my memory. However, changing L to 70000 (I suppose the magic limit is 1<<16), memcheck uses an ever-increasing amount of memory, until the kernel finally kills it.

Is there anything one can do about this? There is obviously no leak, but there appears to be one in valgrind itself (!?), making it difficult to use for checking programs with lots of large and short-lived allocations.

Some background, not sure which is relevant:

$ valgrind --version
valgrind-3.7.0
$ gcc --version
gcc (GCC) 4.4.6 20110731 (Red Hat 4.4.6-3)
$ /lib/libc.so.6
GNU C Library stable release version 2.12, by Roland McGrath et al.
$ uname -rms
Linux 2.6.32-220.2.1.el6.x86_64 x86_64
  • 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-06T13:43:43+00:00Added an answer on June 6, 2026 at 1:43 pm

    This is very likely caused by a gcc 4.4 bug,
    which is bypassed in valgrind 3.8.0 (not yet released)

    extract from Valgrind 3.8.0 NEWS file:

    n-i-bz Bypass gcc4.4/4.5 wrong code generation causing out of memory or asserts

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

Sidebar

Related Questions

Consider this small program: int main(int argc, const char *argv[]) { int *i =
I've posted some questions on this before, but it's different. So consider a small
Consider this #define : #define msd_buffer ((volatile char *) MSD_BUFFER_ADDRESS) and this variable definition:
Consider this code: #define N_ 0 #define N_X 1 #define M(a) N_ M(arg)X; //
I have a small isuse regarding an interface. Consider this code: [HttpPost()] public void
Consider this scenario. I have a small enterprise project dev environment. We use archiva
Consider this small snippet of JavaScript: for(var i in map.maps) { buttons.push($(<button>).html(i).click(function() { alert(i);
Consider this small piece of code from apscheduler.scheduler import Scheduler import time class First():
Hy everyone, pls consider this small code, and help me to figure out, why
Consider this very small contrived subset of my schema: SensorType1 ID : PK SensorType2

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.