|
I have a pointer defined in my header:
unsigned char *m_pData;
In my class constructor I initialize the pointer:
pData = NULL;
In my class source code I allocate memory:
m_pData = new unsigned char[m_fileLen];
In my destructor I delete the memory:
if(m_pData != NULL)
delete [] m_pData;
I keep getting memory leaks when the app is closed...I have set breakpoints and the delete in the destructor is being called. Why am I getting these leaks?
|
|
|
|
|
I hade a typo in the post, should read
m_pData = NULL;
Why am I leaking...need a can of stop leak
|
|
|
|
|
i'll ask an obvious question: how many times are you doing the allocation?
-c
Cheap oil. It's worth it!
|
|
|
|
|
Another obvious question: is the class that contains this code being dynamically allocated, and if so, is that class instance being deleted?
Peace!
-=- James.
"Some People Know How To Drive, Others Just Know How To Operate A Car."
[Get Check Favorites 1.4 Now!]
|
|
|
|
|
Obviously ure allocating it more than once, make sure ure not losing any pointer over there, as a general rule the delete operator should be called as much as the new operator!
(Could be exceptions)
Papa
Murex Co.
|
|
|
|
|
|
Thanks to all that replied...It was the first suggested problem...the app was allocating the memory twice in different places in the code. Sometimes the brain goes numb before the body does...too much overtime...all it took was someone to ask the obvious question, the one my brain wasn't asking.
|
|
|
|
|
can someone please explain what i can do with make files (.mak, .make) in practice? i see options in compilers to make those files everywhere yet i don't see any options to do anything else with them...
It's a mystery to me, please explain or show me where it is explained, i'd be very thankful.
Kuniva
--------------------------------------------
|
|
|
|
|
Look up nmake on MSDN. nmake will allow you to compile .mak files.
Michael
Logic, my dear Zoe, merely enables one to be wrong with authority. - The Doctor
|
|
|
|
|
I'm working on building an integrated tool for MS Dev Studio. I read this article:
http://www.codeproject.com/macro/DevStudioHost.asp
It has an example of how to create an add-in which hosts a GUI within dev studio. In order to create the window within dev studio, I need handles of dev studio:
HINSTANCE hInst = AfxGetApp()->m_hInstance;
DWORD threadID = AfxGetApp()->m_nThreadID;
When the add-in executes, I get an access violation from the above statements. I even tried compiling the source from the article on codeproject and got the same error!?!
Any help would be appreciated.
|
|
|
|
|
you're getting the access violation because AfxGetApp is returning NULL. why it's returning NULL, i can't say without seeing more of your code. where are you calling it from?
-c
Cheap oil. It's worth it!
|
|
|
|
|
I'm building this as an add-in for visual studio. I'm calling it from CDSAddIn::OnConnection. Here is a description of the thinking behind how it all works and some more code.
So, once in the CDSAddIn::OnConnection() method we store off the current CWinApp's hinstance and threadID. Then the AFX_MANAGE_STATE macro is used to switch the state so that our add-ins access to it's resource's will function correctly. Note that the manage state macro is done after the storing of the hinstance and threadID - if we had switched state before, then the values would be different - what we want is to have the hinstance and threadID for the Developer Studio app.
// This is called when the user first loads the add-in, and on start-up
// of each subsequent Developer Studio session
STDMETHODIMP CDSAddIn::OnConnection(IApplication* pApp, VARIANT_BOOL bFirstTime,
long dwCookie, VARIANT_BOOL* OnConnection)
{
HINSTANCE hInst = AfxGetApp()->m_hInstance;
DWORD threadID = AfxGetApp()->m_nThreadID;
AFX_MANAGE_STATE(AfxGetStaticModuleState());
|
|
|
|
|
If you have a CListCtrl, and you set the option to have a border (either through the GUI interface or WM_BORDER option), how do you find the border width ?
|
|
|
|
|
I haven't tried, but I think you can calculate the it by copmuting the difference in width between GetWindowRect and GetClientRect (and dividing by two.)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Look at ::GetSystemMetrics() in MSDN...
int xBorder = GetSystemMetrics(SM_CXBORDER);
int yBorder = GetSystemMetrics(SM_CYBORDER);
|
|
|
|
|
Does anyone know the commands to overide your applications taskbar options?? i.e. - change the right click and left click functionality of the box that sits in the taskbar?? How would i replace the right click menu (you know restore/minimize/maximize/close/etc) to a custom menu??
kevin
|
|
|
|
|
GetSystemMenu gives you a handle to this menu that you can later use to modify it to your taste.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
CMenu *TEMPA;
TEMPA = GetSystemMenu(TRUE);
CMenu *TEMPB;
TEMPB = TEMPA->GetSubMenu(0);
TEMPB->InsertMenu(0, MF_BYPOSITION, ID_CASCADE, "&Cascade");
The result is a crash... any ideas?
kevin
|
|
|
|
|
ok i see it doesnt work like most popups where you have to get the submenu.. my fault - now how do i enable left click functions??? I want my programs child windows to stack and blink ala AOL AIM..
kevin
|
|
|
|
|
Has anyone been having trouble with the new MFC implementation of CString and the debug memory validation code like _CrtIsValidHeapPointer() ?
I am just moving our projects over to VS.NET and it's really pi**ing me off!
I have an extension DLL that seems to cause the problems in CAfxStringMgr::Free() when the program shuts down. I guess compiling release builds may hide this problem but there must still be a problem?!
Anyone got any ideas for working through these issues?
Cheers
|
|
|
|
|
The following used just fine before I reinstalled VC++.. I am not sure what I forgot to install or set:
Set FSO = CreateObject("Scripting.FileSystemObject")
But now this line generates:
ActiveX component can't create object: 'Scripting.FileSystemObject'
Does anyone know what's wrong?
Vitaly Belman
|
|
|
|
|
Hi!
I want to remotely close an app. What I already tried was to use SendMessage() with messages like WM_CLOSE, WM_QUIT, WM_ENDSESSION and so on. I want to close the filesharing program "KaZaA". But for some reason it does not like the messages
WM_CLOSE: Kazaa simply minimizes itself
WM_QUIT: Nothing happens
WM_ENDSESSION: Kazaa quits, but it crashes
Is there another SMOOTH way to close an app so that it still will be able to finish some tasks before quitting?
thanks in advance
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Try using Spy focused on Kazaa to see the messages it receives on closing.
rechi
|
|
|
|
|
Seems like Kazaa processes WM_DESTROY and WM_NCDESTROY, but it doesn't help work if I send them via SendMessage()
modified 12-Sep-18 21:01pm.
|
|
|
|
|
This might be a little tricky, but you could try to simulate the user clicking "Close" in the trayicon menu
Cheers, Marc Click to see my *real* signature
|
|
|
|