memory leak problem - Windows CE

This is a discussion on memory leak problem - Windows CE ; Hi, im having some Critical section handle leak in the camera applition. When using the getsavefile() in one of my save button handling function, the leak occurs. Below is my content of the getsavefilename() int get_save_file_name() { OPENFILENAME ofn; ZeroMemory((LPVOID)&ofn,sizeof*(OPENFILENAME)); ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: memory leak problem

  1. memory leak problem

    Hi,


    im having some Critical section handle leak in the camera applition.


    When using the getsavefile() in one of my save button handling
    function, the leak occurs.


    Below is my content of the getsavefilename()


    int get_save_file_name()
    {
    OPENFILENAME ofn;


    ZeroMemory((LPVOID)&ofn,sizeof*(OPENFILENAME));
    DEFAULT_FILE_PATH[0] = '\0';
    wcscpy(DEFAULT_FILE_PATH,L"cap*ture.jpg\0");


    ofn.lStructSize = sizeof(ofn);
    ofn.hwndOwner = GET_MAIN_WINDOW_HANDLE();
    ofn.lpstrFilter = L"JPEG Files (*.jpg)\0*.jpg\0All Files
    (*.*)\0*.*\0\0";
    ofn.lpstrFile = DEFAULT_FILE_PATH;
    ofn.nMaxFile = JPEG_FILE_NAME_MAX;
    ofn.lpstrDefExt = L"jpg";
    ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
    OFN_OVERWRITEPROMPT;


    return GetSaveFileName(&ofn);



    }


    Pls, advsie me


  2. Re: memory leak problem

    If you are going to ask the same question in multiple newsgroups,
    please post to all groups at the same time, so we can all share all of
    the discussions. You have received responses in the thread you started
    in comp.os.ms-windows.programmer.win32


    On 18 May 2005 20:24:50 -0700, frank.coffeetalk@gmail.com wrote:

    >Hi,
    >
    >
    >im having some Critical section handle leak in the camera applition.


    Which camera application?

    If the problem really is a leak in a Critical Section handle, then the
    code you show is probably not relevant, because it doesn't reference
    any Critical Section.


    >
    >
    >When using the getsavefile() in one of my save button handling
    >function, the leak occurs.
    >
    >
    >Below is my content of the getsavefilename()
    >
    >
    >int get_save_file_name()
    >{
    > OPENFILENAME ofn;
    >
    >
    > ZeroMemory((LPVOID)&ofn,sizeof*(OPENFILENAME));
    > DEFAULT_FILE_PATH[0] = '\0';


    What is the declaration for DEFAULT_FILE_PATH, and where is it?


    > wcscpy(DEFAULT_FILE_PATH,L"cap*ture.jpg\0");
    >
    >
    > ofn.lStructSize = sizeof(ofn);
    > ofn.hwndOwner = GET_MAIN_WINDOW_HANDLE();
    > ofn.lpstrFilter = L"JPEG Files (*.jpg)\0*.jpg\0All Files
    >(*.*)\0*.*\0\0";
    > ofn.lpstrFile = DEFAULT_FILE_PATH;
    > ofn.nMaxFile = JPEG_FILE_NAME_MAX;
    > ofn.lpstrDefExt = L"jpg";
    > ofn.Flags = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY |
    >OFN_OVERWRITEPROMPT;
    >
    >
    > return GetSaveFileName(&ofn);
    >
    >
    >
    >}
    >
    >
    >Pls, advsie me


    -----------------------------------------
    To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

    Robert E. Zaret, eMVP
    PenFact, Inc.
    500 Harrison Ave., Suite 3R
    Boston, MA 02118
    www.penfact.com

  3. Re: memory leak problem

    hi,

    thx for ur advice...

    -"Which camera application?"
    ----->mine is a cmos censor interface .

    -I'm not using any critical section so the Critical section Handle leak
    is very strange.

    -What is the declaration for DEFAULT_FILE_PATH, and where
    is it?
    -#define DEFAULT_FILE_PATH TEXT("\\windows\\capture.jpg")

    Rgds,
    Frank


  4. Re: memory leak problem

    On 24 May 2005 23:51:14 -0700, "frank" wrote:

    >hi,
    >
    >thx for ur advice...
    >
    > -"Which camera application?"
    >----->mine is a cmos censor interface .
    >
    >-I'm not using any critical section so the Critical section Handle leak
    >is very strange.


    That suggests you have a pointer problem someplace else that is
    producing _symptoms_ here.


    >
    > -What is the declaration for DEFAULT_FILE_PATH, and where
    >is it?
    >-#define DEFAULT_FILE_PATH TEXT("\\windows\\capture.jpg")


    This defines it as a pointer to a string _constant_, but the code in
    your original post tries to use it as the target for a wcscpy. Such
    coding is likely to produce strange results. If you've done similar in
    other parts of your code, that could well be the problem. Finding such
    bad code can be _very_ frustrating; I've used MessageBoxes,
    BoundsChecker, and lint. For more info, see a 12-21 Apr 2005 thread
    called "Crashes in Debug (random) but not release" in
    microsoft.public.pocketpc.developer.


    >
    >Rgds,
    >Frank


    -----------------------------------------
    To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

    Robert E. Zaret, eMVP
    PenFact, Inc.
    500 Harrison Ave., Suite 3R
    Boston, MA 02118
    www.penfact.com

+ Reply to Thread