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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:06:54+00:00 2026-06-12T04:06:54+00:00

I have a program, written in C, it uses Berkeley-Db, glib-2, and libxml-2. It

  • 0

I have a program, written in C, it uses Berkeley-Db, glib-2, and libxml-2. It is a search indexer which makes NLP with syntactic and semantic analysis, and stores conceptual structures in search indices instead of words.

However, I have a problem — after a day or so, my program runs out of memory.

When I try to run my program under valgrind, it works very slow, it seems to me, that 10 times slower than with normal run.

All my attempts to check for memory-leaks (made for weeks under valgrind or so) didn’t show any leaks.

Does anybody know some tools that can help me in this situation?

  • 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-12T04:06:55+00:00Added an answer on June 12, 2026 at 4:06 am

    my solution would be:

    #define malloc(size) mymalloc(size, __FILE__, __FUNCTION__, __LINE__)
    ... (realloc, calloc, free)
    
    void *mymalloc(size_t size, char *file, char *function, int line)
    {
      void *data = malloc(size);
      addList(data, size, file, function, line);
      return data;
    }
    
    void myfree(void *data)
    {
      removeList(data);
      free(data);
    }
    
    void debugalloc()
    {
      printList();
    }
    

    the removeList() would search for “data” in the global list and remove it, or gives a warning. with “debugalloc();” you should print the whole list (and normally it should be empty, or well filled with what you expect it to have).

    Another option:
    your memory management gets fragmented, … (upps, Alexey Frunze wrote that just a second ago in the comments section.)

    EDITH: XML

    I made a comment about DOM and SAX, and I have the feeling just to expand this comment:

    <head><data>...</data><data>...</data>......<data>...</data></head>
    

    is an excellent candidate for SAX. In DOM, the whole XML will be read and converted into memory, which can lead very quickly to fragmented memory, if < data > itself is structured with different sized values. it may happen, that your operating system’s memory modell will work against mallocing small amounts of memory.

    With SAX, you only load portions of data into memory and get rid of it as soon as it is consumed. But your implementation must change from traversing the Document into a kind of State Machine with feeding (< data >) and consuming/processing (< / data >).

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

Sidebar

Related Questions

I have a simple program (written in Java) which uses the google protocol buffer
I have a main program written in C# which creates and uses objects written
I have a program written in VB.NET which stops a service that uses file
I have written a program which uses CardLayout. I want it to show a
I have written sample program which uses XSLT to generate HTML response. Check below
I have a program written in C++ which uses dlopen to load a dynamic
I have a program written in Java which uses 3 threads. Everything is working
I have written a program which uses a SQL exception class and then use
I have written a small program which uses function pointers to do some numerical
I have a program written in VB.Net (Visual Studio 2008) that uses a DLL

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.