Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

mostafa_pasha

@mostafa_pasha
About
Posts
76
Topics
33
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Memory leak!
    M mostafa_pasha

    Yes, I test it inside a large application. But Does it depend?

    C / C++ / MFC data-structures debugging performance help question

  • Memory leak!
    M mostafa_pasha

    But i got memory leak in VS2008 SP1!!! Is it a bug? or there is something wrong in my code? Best, MJM

    C / C++ / MFC data-structures debugging performance help question

  • Memory leak!
    M mostafa_pasha

    Here is a code for create and delete a 3D array! when i try to catch memory leak by the following code, It alerts that i have exactly 1600 bytes memory leak! Where is the problem of my Code?

    #define VAR_TYPE double

    VAR_TYPE ** Create2Darray(int n, int l)
    {
    VAR_TYPE **temp = new VAR_TYPE*[n];
    for (int i =0 ; i< n ; i++) temp[i] = new VAR_TYPE[l];
    return temp;
    }
    VAR_TYPE *** Create3DArray(int x,int y,int z)
    {
    VAR_TYPE *** arrayd;
    arrayd = new VAR_TYPE**[x];
    for (int i =0 ; i< x ; i++) arrayd[i] = Create2Darray(y,z);
    return arrayd;
    }

    void Delete3DArray(VAR_TYPE *** darray,int Xdim,int Ydim,int Zdim)
    {
    for (int k =0; k<Xdim;k++)
    {
    for (int j=0; j<Ydim;j++)
    {
    delete [] darray[k][j];
    darray[k][j]=NULL;
    }
    delete [] darray[k];
    darray[k] = NULL;
    }
    delete [] darray;
    darray = NULL;
    }

    //code for detect memory leak

    #ifdef _DEBUG
    CMemoryState msOld,msnew, diffMemState;
    msOld.Checkpoint();
    double *** Sample_Temp = Create3DArray(182,218,182);
    Delete3DArray(Sample_Temp,182, 218, 182);

    msnew.Checkpoint();
    if( diffMemState.Difference(msOld, msnew) )
    {
    	TRACE( "Memory leaked!\\n" );
    	diffMemState.DumpStatistics();
    }
    

    #endif

    the output ofter running diffMemState.DumpStatistics() : Memory leaked! 0 bytes in 0 Free Blocks. 120 bytes in 2 Normal Blocks. 0 bytes in 0 CRT Blocks. 0 bytes in 0 Ignore Blocks. 0 bytes in 0 Client Blocks. Largest number used: 57659956 bytes. Total allocations: 57661556 bytes. Best, MJM

    C / C++ / MFC data-structures debugging performance help question

  • GDI+ Problem!
    M mostafa_pasha

    the code is here: HBITMAP hbmp1 = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)); ASSERT(hbmp1!=NULL); Bitmap* pBmp1 = Bitmap::FromHBITMAP(hbmp1,NULL); hbmp1 0xb8051055 pBmp1 0x00000000 in LoadBitmap function: inline Bitmap* Bitmap::FromHBITMAP( IN HBITMAP hbm, IN HPALETTE hpal ) { return new Bitmap(hbm, hpal); } void* (operator new)(size_t in_size) { return DllExports::GdipAlloc(in_size); } in_size = 16 return 0x000000000 Best, MJM

    C / C++ / MFC graphics question winforms help

  • GDI+ Problem!
    M mostafa_pasha

    return NULL It means can not initilaize Bitmap!!! Does it mean it can not initialize the GDI+? inline Bitmap* Bitmap::FromHBITMAP( IN HBITMAP hbm, IN HPALETTE hpal ) { return new Bitmap(hbm, hpal); }

    C / C++ / MFC graphics question winforms help

  • GDI+ Problem!
    M mostafa_pasha

    first, it is runtime error! I said that when i debug the code under windows XP! (it means i can compile and run the program), pBmp1 which is the GDI+ object is NULL!!! but under windows vista/7, All is OK. My program is MDI. My project setting is USED MFC LIBRARY AS SHARED DLL! Does it depend on the updates for windows XP or Not? Best, MJM

    C / C++ / MFC graphics question winforms help

  • GDI+ Problem!
    M mostafa_pasha

    I use GDI+ in my project under windows Vista/7 without any problems. But when i try to compile the code or run the code under windows XP, the program crashes/ the compiler throw an exception. I found that pBmp1 is NULL under the windows XP: HBITMAP hbmp1 = ::LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_BITMAP1)); ASSERT(hbmp1!=NULL); Bitmap* pBmp1 = Bitmap::FromHBITMAP(hbmp1,NULL); ASSERT(pBmp1->GetLastStatus() == Ok); How can i Correct it? Best, MJM

    C / C++ / MFC graphics question winforms help

  • Runing the MFC program in Silent Mode.
    M mostafa_pasha

    Is there any way to run a MDI/SDI MFC application in silent mode and pass some files to it? Best, MJM

    C / C++ / MFC c++ question

  • Unstable Thread runs!
    M mostafa_pasha

    Unfortunately, I used SetEvent , .... in the debug mode, everything is OK. in the release mode, it seems that the threads can not start!!! Best, MJM

    C / C++ / MFC help

  • Unstable Thread runs!
    M mostafa_pasha

    I taught coping the software is for thread priority.So i tried to change the priority to ABOVE_NORMAL. About debugging, i changed the code: WinThread* first=NULL; first = AfxBeginThread(MyThreadProcT, &pmom1,THREAD_PRIORITY_ABOVE_NORMAL); if(first == NULL) { AfxMessageBox(_T("Can not run a thread!!!")); return; } CWinThread* second=NULL; second = AfxBeginThread(MyThreadProcT1, &pmom2,THREAD_PRIORITY_ABOVE_NORMAL); if(second == NULL) { AfxMessageBox(_T("Can not run a thread!!!")); return; } if (WaitForSingleObject(first->m_hThread, INFINITE) == WAIT_FAILED) { ErrorExit(TEXT("Thread_First")); // show the GetLastError } if (WaitForSingleObject(second->m_hThread, INFINITE)) { ErrorExit(TEXT("Thread_Second")); // show the GetLastError } I caught this message box: Thread_Second failed with error 6: The Handle is invalid!!! Does it mean second thread finish before the the first thread? Best MJM

    C / C++ / MFC help

  • Unstable Thread runs!
    M mostafa_pasha

    I run a worker thread like this: m_first = AfxBeginThread(MyThreadProcTT1, segmentation,THREAD_PRIORITY_ABOVE_NORMAL); in the MyThreadProcTT1, i run four worker threads like this: CWinThread* first=NULL; first = AfxBeginThread(MyThreadProc, pNewObject,THREAD_PRIORITY_ABOVE_NORMAL); second = AfxBeginThread(MyThreadProc1, pNewObject1,THREAD_PRIORITY_ABOVE_NORMAL); third = AfxBeginThread(MyThreadProc2, pNewObject2,THREAD_PRIORITY_ABOVE_NORMAL); forth = AfxBeginThread(MyThreadProc3, pNewObject3,THREAD_PRIORITY_ABOVE_NORMAL); WaitForSingleObject(first->m_hThread, INFINITE); WaitForSingleObject(second->m_hThread, INFINITE); WaitForSingleObject(third->m_hThread, INFINITE); WaitForSingleObject(forth->m_hThread, INFINITE); in most of the time, the program work fine. But in some situations, the program halts and do not anything! Is there anyone can help me! Best, MJM

    C / C++ / MFC help

  • __non_rtti_object
    M mostafa_pasha

    i compile in debug mode & there is no run-time or exception! But when i compile in release mode there is __non_rtti_object exception! how can i find which pointer is null that cause this exception in release mode? Best Regards, M.J.M.

    C / C++ / MFC question debugging announcement

  • CDialog access !
    M mostafa_pasha

    I have progress bar, i want to change position from my CMyFile class ! CMyFile class is generic class! i just want to change position of bar from my CMyFile so first , i get pointer to my dialog class form CMyFile! then call function SetPos() of my prograss bar class . How can i do that? best regards. MJM

    C / C++ / MFC question

  • CDialog access !
    M mostafa_pasha

    Hi, it does not work. GetParent get one argument as HWND. i change it , CMainClass *m_Main=(CMainClass*)GetParent(theApp.GetMainWnd()->m_hWnd); but in dialog base application , compiler say " error C2065: 'theApp' : undeclared identifier" now how can i get pointer to CVerApp class? CVerApp * = ???; which function exist to point to my CVerApp? Best Regards. M.J.M.

    C / C++ / MFC question

  • CDialog access !
    M mostafa_pasha

    for example i have CMyFile that is generic class (my project is CDialog base such as CMyDialog) how can i access CMyDialog through CMyFile? is that anyway that call CMyDialog's function from CMyFile class? Best regards. M.J.M.

    C / C++ / MFC question

  • CDialog access !
    M mostafa_pasha

    How can i access CDialog class from antoher class that declare in CDialog base application? best regards, M.J.M.

    C / C++ / MFC question

  • Memory Overrun! in MFC
    M mostafa_pasha

    Hi, but there is not diffrence , i think before i must use delete [] when i create two dimensional array in heap such as this: vf_Weigth = new float* [nlayer2+1]; for ( i =0 ; i< (nlayer2+1) ; i++) vf_Weigth[i] = new float[nlayer1]; delete [] vf_Weigth; // but now i find i delete in these way: for (int i = 0; i < nlayer2+1 ; i++) delete vf_Weight[i]; is that code is correct? at last i say again delete [] Pitch is not work & my code have that serios error. Best Regards. M.J.M.

    C / C++ / MFC c++ performance help question

  • Memory Overrun! in MFC
    M mostafa_pasha

    excuse me for this fault, i do not know when i ignore HTML tags , the messeage is correct:confused: Netmfile.z = sizeCB * N - (sizeCB-1) * (N/2); //double *smp2; smp2 = new double [Netmfile.z]; for (i=0 ; iN/2) { for ( j=p ; j>=i+1 ; j--) pichi [ j ] = pichi [ j - 1 ] ; pichi [ i ] = N/2; pichi [ i + 1 ] = m - N/2; m=0; p++; //beacause of increase of Pitch length in each atage } i++; } return (p);

    C / C++ / MFC c++ performance help question

  • Memory Overrun! in MFC
    M mostafa_pasha

    excuse me for delay to response, //OVERRUN is for Pitch array .... char *BeginFile = NULL; BeginFile = new char[44]; try { File.Read(BeginFile,44); } catch(CFileException *pe) { pe->ReportError(); } DWORD dwLength = (File.GetLength()-44); char *inChar ; inChar = new char[800000]; try { File.Read(inChar,dwLength); } catch(CFileException *pe) { pe->ReportError(); } File.Close(); int tmp; unsigned char c1,c2; double *in ; in = new double[400000]; int smp=dwLength/2; const int fs=22050; const int fc=7500; int kc = floor( (double)(fc * N / fs) )+1; int len=ceil((double)smp/N*2)+1; double *CBn ; CBn = new double[kc*len]; int sizeCB; sizeCB = Netmfile.Feature( in , kc ,smp , CBn ); int *Pitch = NULL; Pitch = new int[3000]; // :wtf:if use 2000 have OVERRUN PROBLEM IF use 3000 DO NOT HAVE OVERRUN PROBLEM:omg: // PitchExtract shown below int LenPitch = Netmfile.PitchExtract( in ,smp ,Pitch ); delete in; delete BeginFile; delete in; delete BeginFile; char weigthpath[]="text\\"; //path of MAT to TXT file double *CB1t ; CB1t = new double [kc*len]; Netmfile.net( CBn , CB1t , kc , weigthpath , sizeCB ); Netmfile.z = sizeCB * N - (sizeCB-1) * (N/2); smp2 = new double [Netmfile.z]; for (i=0 ; iN/2) { for ( j=p ; j>=i+1 ; j--) pichi [ j ] = pichi [ j - 1 ] ; pichi [ i ] = N/2; pichi [ i + 1 ] = m - N/2; m=0; p++; } i++; } return (p); }

    C / C++ / MFC c++ performance help question

  • Memory Overrun! in MFC
    M mostafa_pasha

    Hi, I have function that i allocate very large data in Heap, after i create with new & use it when i want to delete these , there is memory overrun error & i do not know how can i solve that!

    C / C++ / MFC c++ performance help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups