long time sound recording problems

hello
I have developed a program which listens to the user's and responds with some answer from the database. when I use this software for some time like 1.5 to 2 hrs, at some abrupt time the application suddenly stops recording and there ends the process.
Iam coding in VC++ 6.0, WinAPI.
OS - XP
RAM - 128MB
please help


Regards
srikanth
«1

Comments

  • jasonjason United Kingdom
    Could be a million and one things. 128mb of ram is not very high when using XP, add that to a possible memory leak in your code and you might find the application is quitting due to out of memory problems.

    Have a look at the task manager whilst your code is running. Also, are you catching exceptions in your code when requesting memory from the heap?

    Regards, Jason
  • thanks jason
    please suggest me how to check the memory leaks.
    the task manager always shows 1226kb consumption of memory and 2-5 of the cpu load randomely.
    as of now Iam not catching any of the exceptions.
    if the requested memory is not allocated the what to do.
    In the same condition(system configuration) a winamp(upto 4hrs continous audio) is woking fine.

    please suggest


    Regards
    srikanth

  • jasonjason United Kingdom
    [b][red]This message was edited by jason at 2004-3-14 1:25:33[/red][/b][hr]
    [b][red]This message was edited by jason at 2004-3-13 11:52:15[/red][/b][hr]
    There are several utilities that monitor memory and will show the number of handles to memory in the heap. Borland C++ Builder comes with one but i'm not sure about MS Visual Studio as I haven't had it long. You need to run the utility and your application simultaneously and see if your application fails to free any dynamically allocated memory on exit.

    Let's say you need a block of memory from the heap.
    Typically in C you might use:

    int *myPtr = malloc( sizeof( int ) *1000 );
    if ( myPtr )
    {
    /* do something with the memory here */
    }
    else
    {
    /* handle the error */
    }

    In C++ you might use the try, throw and catch statements.

    try
    {
    // allocate memory for a new class on the heap
    MyClass *myClassPtr;
    myClassPtr = new MyClass;
    }
    catch ( Exception &e )
    {
    cout << "Error allocating memory!" << endl;
    }

    Hope this helps. Regards, Jason




  • Thanks Mr.Jason
    i'll try the code and come back.

    can you give me some guidance about how to have an entry in
    msconfig >>startup. How to add and delete an entry completely.


    thanks


    Regards
    srikanth

  • jasonjason United Kingdom
    The command to run processes at startup is contained in the registry. I think its somewhere like

    HKEY_LOCAL_MACHINE->SOFTWARE->Microsoft->Windows->CurrentVersion->Run

    Use regedit to have a look. You can delete the key of the process you don't want the system to load at startup.

    Don't quote me on this as I haven't really got involved with the registry. You can alter the registry programmatically - see MSDN for details.

    Regards, Jason
  • Hi,

    : I have developed a program which listens to the user's and responds with some answer from the database. when I use this software for some time like 1.5 to 2 hrs, at some abrupt time the application suddenly stops recording and there ends the process.
    : Iam coding in VC++ 6.0, WinAPI.
    : OS - XP
    : RAM - 128MB
    : please help
    :
    I'm guessing this is the exact same "abrupt time" everytime you do this, right? :-) I've read the threads on memory leaks etc and very much doubt it's to do with that. It's much more likely to do with you reaching the maximum range of a given datatype.

    Take your signed int, for example. It has a maximum value of 2^31 - 1. That may seem a big value, until you think like this:-

    44100 sampling rate * 2 channels * 2 bytes per sample = 176400 bytes of data per second

    2^31 / 176400 = 12173 seconds = 202 minutes ~= 3 and a bit hours

    You may be using these values in a different way, and encounter this issue before my suggested limit of 3 hours like you mention - in terms of orders of magnitude we're pretty close. I very much suspect that this issue may be at the heart of your problems.

    If you look on my list of stuff to do with AMaMP I've already flagged this up as "Something ugly that will have to be dealt with some day". Using 64 bit integers is a possible solution, depending upon their availability. Of course, once you've dealt with stuff inside your app you still have to look at things at an OS level, which is probably going to be even more nasty.

    I guess a little extension is possible by using an unsigned int...

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • jasonjason United Kingdom
    Hi Jonathan & Srikanth.

    Yeh, I can see where you're coming from Jonathan. A quick question though Srikanth, does your program monitor ie "listen" to the user's vocal input, or does it "record" it? Maybe your program does both I don't know, but I would guess that the integer overflow issue described by Jonathan would probably apply more to recording.

    Anyway, keep us informed.

    Regards, Jason
  • Hi Jonathan & jason

    iam recording the data to the hard disk.
    i moniter the signal,display the time domain and the frequency domain
    of the signal.
    iam using 8-bit unsigned,mono,6000 sampling rate.

    iam recording 3sec for every 4sec.
    is it ok to every time deallocate and reallocate the buffers.
    or is it a redundant job.



    Regards
    srikanth

  • jasonjason United Kingdom
    : Hi Jonathan & jason
    :
    : iam recording the data to the hard disk.
    : i moniter the signal,display the time domain and the frequency domain
    : of the signal.
    : iam using 8-bit unsigned,mono,6000 sampling rate.
    :
    : iam recording 3sec for every 4sec.
    : is it ok to every time deallocate and reallocate the buffers.
    : or is it a redundant job.
    :
    :
    :
    : Regards
    : srikanth
    :
    :

    Hi. I guess it is a redundant job.

    Regards, Jason

  • hi
    will any use of third party software help me out of this problem so that they manage memory handinlg in a better way ?



    Regards
    srikanth

  • Hi,

    Sorry I didn't get back to you for a while...health problems got in the way and I forgot your question was still needing a reply. :-)

    : will any use of third party software help me out of this problem so
    : that they manage memory handinlg in a better way ?
    :
    I very much doubt that the Win32 APIs themselves would be the problem. I can sit and listen to music on my PC for many hours without running into problems, so internally they probably just pass the buffers of data you give them on to the soundcard driver. So I struggle to believe it's memory handling either, as we've already determined that stays stable.

    If you look at loop conditions and other conditionals, you may well be able to see some that would cause the program to quit if a variable rolled over from its maximum range and went back to zero, or a large negative value (depends on whether you're using signed or unsinged ints). That'd be my first thing to look at.

    It's nasty and VERY evil, but have you tried using a double instead of an integer data type? I don't really like to recommend this though. I'd much sooner recommend 64 bit integers if you have access to such a type through your compiler. Take a look and try using those. You need to identify the conditions when your program exits though. Is there anything you can change to make this happen sooner, for example? I may be wrong on my theory of why it's exiting at a certain point in time, but if it runs for exactly the same amount of time each time then exits this just seems very likely to me.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • hi
    is there any chance that the locked buffers for a long time does not remain locked.

    iam monitoring the signal and the count does not exceed 50, if the returned buffers count reaches 50 the count is set to 0.
    so at any point of time the count of the all the variables does not exceed the max value(32 bit unsigned integer).
    the application does not stop all the times at a particular time.
    If there are 5-6 instances of the internet explorers opened then the application stops at an early time, if no IE's then the applpication runs for a long time.

    how to manage and tackle the problem sucessfully please help.
    Regards
    srikanth

  • : is there any chance that the locked buffers for a long time does not remain locked.
    :
    What do you mean by locked buffers?

    : iam monitoring the signal and the count does not exceed 50, if the returned buffers count reaches 50 the count is set to 0.
    : so at any point of time the count of the all the variables does not exceed the max value(32 bit unsigned integer).
    : the application does not stop all the times at a particular time.
    OK, which makes my theory somewhat more unlikely.

    : If there are 5-6 instances of the internet explorers opened then the application stops at an early time, if no IE's then the applpication runs for a long time.
    :
    : how to manage and tackle the problem sucessfully please help.
    :
    Maybe Jason was right in that it's a memory management issue. Or more to the point, memory mis-management. While you may not be leaking, C apps are notorious for having odd behaviour because a bit of memory gets corrupted by your program. Unfortunately, there isn't a lot more that I can do. You're just going to have to go to your code with a debugger and try and reproduce the problem under the debugger, then figure out the state that causes the app to terminate unexpectedly. Use Visual C++ if you have access to it; it's good at tracing bad memory management and damage.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • hi jonathan

    :What do you mean by locked buffers?

    to lock the sound data(buffer) and to send to the device driver. this is what i mean by saying buffer.

    is it not the way ?

    please clarify...

    probably the most ugly thing is that i don't know how to debug the code using VC++. I have coded my app in VC++ winapi.

    any guidance is highly appreciated.
    thanks


    Regards
    srikanth

  • : :What do you mean by locked buffers?
    :
    : to lock the sound data(buffer) and to send to the device driver.
    : this is what i mean by saying buffer.
    :
    : is it not the way ?
    :
    : please clarify...
    :
    To my understanding, when you use waveOutWrite to write a buffer of data you should not try and modify data in the buffer after it has been written as the soundcard device driver may lock it. But it depends on the driver. Or is what not what you meant? When you are getting data by waveIn APIs, I would imagine any data you are passed is not locked in any way.

    : probably the most ugly thing is that i don't know how to debug the code using VC++. I have coded my app in VC++ winapi.
    :
    Debugging is just a skill you have to learn. You can run your app under the debugger using Build ==> Debug ==> Go. You can insert break points by right clicking on a line of code and choosing insert breakpoint. You can manipulate your program's data as it runs, see contents of variables, etc. See the Visual Studio docs.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories