Menu

Sphinx 3 memory leak in MFC app

Help
Liu
2006-08-23
2012-09-22
  • Liu

    Liu - 2006-08-23

    Does anyone know why there's a huge memory leak in an MFC app using Sphinx 3? I have a simple MFC program that all it does is something similiar to live_pretend sample program; after it exited I saw a lot of memory leak in the debugger (Visual C++ 6.0). The same program has no memory leak if no MFC libs are used. Any suggestions will be greatly appreciated. Here is the simple program:

    _chdir("C:\SphinxASR\hub4");
    live_decoder_t decoder;
    if (cmd_ln_parse_file(arg_def, "ARGS") == 0)
    {
    if (ld_init(&decoder) == LD_SUCCESS)
    {
    short samples[SAMPLE_BUFFER_LENGTH];
    FILE rawfd = NULL;
    int len;
    char
    hypstr;
    if ((rawfd = fopen("speaker2.wav", "rb")) != NULL)
    {
    if (ld_begin_utt(&decoder, "speaker2") == LD_SUCCESS)
    {
    len = fread(samples, sizeof(short), SAMPLE_BUFFER_LENGTH, rawfd);
    while (len > 0)
    {
    ld_process_raw(&decoder, samples, len); ld_retrieve_hyps(&decoder, NULL, &hypstr, NULL);
    len = fread(samples, sizeof(short), SAMPLE_BUFFER_LENGTH, rawfd);
    }
    fclose(rawfd);
    ld_end_utt(&decoder);
    }
    }
    ld_finish(&decoder);
    cmd_ln_appl_exit();
    }
    }

     
    • The Grand Janitor

      This deserves attention. I will file a priorty 8 bug report and try to fix it as quickly as I can.

      Liu, could you also describe the way how you compile the program in MFC 6?

      -a

       
    • Liu

      Liu - 2006-08-23

      I rebuilt all the Sphinx3 libs (with debug multh-threaded in the settings) in MFC 6 first. The MFC app I built the settings (debug build) is as follows:
      General - Use MFC in a Shared DLL
      C/C++ - Code generation using (Debug multi-threaded DLL); defines are (WIN32,_DEBUG,_WINDOWS,_AFXDLL,_MBCS)
      Linking - the inputs are all the sphinx 3 libs.

      If you want I can zip all the files for the build (including the sphinx 3 libs) and email it to you. Thanks for your help. The wave file I tested is a file named speaker2.wav (about 160k in size). Oh here is the debug output and maybe you can get some ideas why the leaks:

      Loaded 'ntdll.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\MFC42D.DLL', no matching symbolic information found.
      Loaded symbols for 'C:\WINDOWS\system32\MSVCRTD.DLL'
      Loaded 'C:\WINDOWS\system32\gdi32.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\user32.dll', no matching symbolic information found.
      Loaded symbols for 'C:\WINDOWS\system32\MFCO42D.DLL'
      Loaded 'C:\WINDOWS\system32\shimeng.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\imm32.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\lpk.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\usp10.dll', no matching symbolic information found.
      Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
      Detected memory leaks!
      Dumping objects ->
      {3466657} normal block at 0x0C68FDC8, 338008 bytes long.
      Data: < D e 5 > 00 00 8B 02 8F 0B 44 81 01 00 8C 02 65 05 35 92
      {3466650} normal block at 0x0F5B0BB0, 52 bytes long.
      Data: < B j [ > 85 0B E2 42 FE 6A F8 C1 BB 03 AC C0 5B C0 B4 C0
      {3466649} normal block at 0x0F5B0C10, 52 bytes long.
      Data: <6 @ -\ \g > 36 AB 90 40 CB FC 9E BF BC 2D 5C BE 9D 5C 67 BE
      {3466579} normal block at 0x046C1AA8, 1024 bytes long.
      Data: < ! ?> 00 00 00 00 00 00 00 00 84 C7 DE FC D1 21 89 3F
      {3466578} normal block at 0x046C1660, 1024 bytes long.
      Data: < ? b ?> 00 00 00 00 00 00 F0 3F DB 92 9B 16 62 FF EF 3F
      {3466569} normal block at 0x0F5B0D00, 9 bytes long.
      Data: <speaker2 > 73 70 65 61 6B 65 72 32 00
      Object dump complete.
      The thread 0x2D0 has exited with code 0 (0x0).
      The program 'C:\temp\testasr2\Debug\testasr2.exe' has exited with code 0 (0x0)

       
      • The Grand Janitor

        Does it work single thread? Sphinx 3 hadn't been tested on a multi-threaded situation yet.

        -a

         
    • Liu

      Liu - 2006-08-29

      I rebuilt all the sphinx3 libs with the single-threaded (/ML) code generation option and I was able to link it with my DLL. The memory problem goes away when I do that. However, I cannot use these single-threaded libs if I want to link it with a multi-threaded apps tho. At least for now I can go on with my DLL. Thanks for the input.

       
      • The Grand Janitor

        At this point, I guess it is out of the Sphinx Developers limit to support multi-thread ports of sphinx3. So I will temporarily change this problem from a bug to a feature request.

        However, never say never. It am still interested in possible implementation that could make the current code multi-threaded. Kindly update me as well.
        -a

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.