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

  • Home
  • SEARCH
  • 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 6563273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:48:38+00:00 2026-05-25T13:48:38+00:00

I have a curious memory leak, it seems that the library function to_unbounded_string is

  • 0

I have a curious memory leak, it seems that the library function to_unbounded_string is leaking!

Code snippets:

procedure Parse (Str    : in     String;

… do stuff…

declare
   New_Element : constant Ada.Strings.Unbounded.Unbounded_String :=
     Ada.Strings.Unbounded.To_Unbounded_String (Str); -- this leaks
begin

valgrind output:

==6009== 10,276 bytes in 1 blocks are possibly lost in loss record 153 of 153
==6009==    at 0x4025BD3: malloc (vg_replace_malloc.c:236)
==6009==    by 0x42703B8: __gnat_malloc (in /usr/lib/libgnat-4.4.so.1)
==6009==    by 0x4269480: system__secondary_stack__ss_allocate (in /usr/lib/libgnat-4.4.so.1)
==6009==    by 0x414929B: ada__strings__unbounded__to_unbounded_string (in /usr/lib/libgnat-4.4.so.1)
==6009==    by 0x80F8AD4: syntax__parser__dash_parser__parseXn (token_parser_g.adb:35)

Where token_parser_g.adb:35 is listed above as the “– this leaks” line.

Other info: Gnatmake version 4.4.5. gcc version 4.4 valgrind version valgrind-3.6.0.SVN-Debian, valgrind options -v –leak-check=full –read-var-info=yes –show-reachable=no

Any help or insights appreciated,

NWS.

  • 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-05-25T13:48:39+00:00Added an answer on May 25, 2026 at 1:48 pm

    Valgrind clearly says that there is possibly a memory leak. It doesn’t necessarily mean there is one. For example, if first call to that function allocates a pool of memory that is re-used during the life time of the program but is never freed, Valgrind will report it as a possible memory leak, even though it is not, as this is a common practice and memory will be returned to OS upon process termination.

    Now, if you think that there is a memory leak for real, call this function in a loop, and see it memory continues to grow. If it does – file a bug report or even better, try to find and fix the leak and send a patch along with a bug report.

    Hope it helps.

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

Sidebar

Related Questions

The following code snippet has a memory leak that I spent too much time
I don't have a code example, but I'm curious whether it's possible to write
I have an stored procedure that works on an table that contains xml field,
I am curious how PHP handles variables in memory? If I have 100 constants
For the curious : It turns out my memory leak had nothing to do
I'm curious what happens with the memory of the objects that I push with
I have looked at the key-value database Redis and am curious about alternatives that
I have troubles finding a memory leak which then again causes my App to
Just curious. Does anyone have experience with both. My gut feeling is that QT
I have a curious question about efficiency. Say I have a field on a

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.