[prev in list] [next in list] [prev in thread] [next in thread]
List: aspell-user
Subject: Aspell memleak!?
From: Linas Vepstas <linasvepstas () gmail ! com>
Date: 2023-01-16 22:11:44
Message-ID: CAHrUA37ixqhrbfupod57XOnwPDt2tFKY4hRsedjVz1mW_d6bYA () mail ! gmail ! com
[Download RAW message or body]
Any advice on the following? After a few days of debugging, I've isolated
what appears to be an aspell meleak. The program below leaks 64 bytes per
spelling suggestion, or about a gigabyte in a few minutes. As far as I can
tell, the program is written in exactly the style that the documentation
calls for. Am I missing something?
This is on Debian stable, version 0.60.8-3
#include <malloc.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <aspell.h>
// Compile with
// cc aspell-memleak.c -laspell
int main()
{
AspellConfig *config = new_aspell_config();
aspell_config_replace(config, "lang", "en_US");
AspellCanHaveError *spell_err = new_aspell_speller(config);
AspellSpeller *speller = to_aspell_speller(spell_err);
size_t k=0;
char* word = "asdf";
for (int l=0; l<1000000; l++)
{
/* Returns 1 is the word is in dict. */
int found = aspell_speller_check(speller, word, -1);
// printf("Found the word: %d\n", found);
const AspellWordList *list = aspell_speller_suggest(speller, word, -1);
AspellStringEnumeration *elem = aspell_word_list_elements(list);
unsigned int size = aspell_word_list_size(list);
const char *aword = NULL;
while ((aword = aspell_string_enumeration_next(elem)) != NULL)
{
// printf("Spell suggesion: %s\n", aword);
k++;
}
delete_aspell_string_enumeration(elem);
if (0 == l%20000)
{
printf("Loop count= %d spell suggests= %lu\n", l, k);
malloc_stats();
}
}
delete_aspell_speller(speller);
delete_aspell_config(config);
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic