|
hi, all
code is,
----------------------------
CDialog * dlg;
while(TRUE)
{
dlg = new MyDialog;
dlg->Create(IDD_DIALOG, this);
Sleep(500);
dlg->DestroyWindow();
Sleep(500);
}
----------------------------
MyDialog is CDialog subcalssing,
MyDialog virtual method override PostNcDestroy()
void MyDialog::PostNcDestroy()
{
delete this;
CDialog::PostNcDestroy();
}
----------------
this code do not always memory leak.
but some time increase using memory. for 4kb... and not decrease using memory
What is problem??
|
|
|
|
|
is there some memory allocated in the constructor of the dialog, and not released in the destructor ?
also, how are you mesuring that memory ?
|
|
|
|
|
gamja wrote:
void MyDialog::PostNcDestroy()
{
delete this;
CDialog::PostNcDestroy();
}
You are calling a member function of your object *after* deleting it.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
If you believe you have memory leaks by looking at the Task Manager, you cannot trust the TM to tell you much about memory usage.
The code you've posted is fine, and doesn't leak memory. The Task Manager reports the amount of memory allocated to your process (the working set). When you initially release memory (no longer need it) the task manager does not immediately return that memory to available space - it holds on to it for a while.
You can probably see this if you display your dialog and then close it (you'll see that 4KB in the Task Manager). Next, minimize your application window and watch the task manager, then restore your window.
Hope that helps.
BTW - your PostNCDestroy is fine.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
gamja wrote: this code do not always memory leak.
but some time increase using memory. for 4kb... and not decrease using memory
How are you verifying this?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
verifying is simple.
Sleep time set short..
another example.
1. make project dialog base project.
2. dlg class, add subclass CDialog
3. dlg class, add member variable CDialog * m_dlg
4. dlg class set timer(Elapse 100ms, if possable more short!), and timer method define
5.
void Ctest1Dlg::OnTimer(UINT_PTR nIDEvent)
{
m_dlg = new MyDialog;
m_dlg->Create(IDD_MYDIALOG, this);
m_dlg->DestroyWindow();
delete m_dlg;
CDialog::OnTimer(nIDEvent);
}
5. build, and debug.
6. look task manager..
-----------------------------------
this project, fastest dialog new, and delete...
|
|
|
|
|
Hi All,
I am using Qt 4 integrated with Visual C++ 2005. In my project, i have some functions, that are called are called frequently. so i want to create a dll of those required functions and call them so that compiling time become less. Can you give some link related to this or any ideas?
With Regards,
Sangeetha.
|
|
|
|
|
|
Hi,
I have gone through it.. but its different in Visual C++ 2005. Please guide in that.
With Regards,
Sangeetha.
|
|
|
|
|
what do you find to be different ?
|
|
|
|
|
Hi,
In command line i could not delete the \D <proj_name> as they asked to do so in Step 3 in the link you referred.
With Regards,
Sangeetha.
|
|
|
|
|
this is done in the project settings for the compiler/linker...
right click on your project for its settings, and search for the parameter which is equivalent of the /D switch...
|
|
|
|
|
Yeah in the Project -> properties -> ConfigurationProperties -> C/C++ -> Command Line i tried.. But its not editable. Can u check in yours..?
With Regards,
Sangeetha.
|
|
|
|
|
Sangeetha_J wrote: Yeah in the Project -> properties -> ConfigurationProperties -> C/C++ -> Command Line i tried.. But its not editable
yeah, that's a summary of what's configured, and passed to the compiler at compile time.
and the settings you find in the property page are configured earlier in the dialog.
please use your brain (and your doc !)
|
|
|
|
|
If you want to exclude some functions in a DLL just hava a look at some articles on codeproject.com that describe how to develop a library.
|
|
|
|
|
Any info example or link with tutorial is welcome i searched google and didnt find nothing good.
I want to patch the call of the function so not do modify the original bytes of the function. I dunno if patching is same as redirection buth searched info for bouth didnt find anything. I want to redirect / patch a dll function return address to my addres ok thnx .
|
|
|
|
|
I don't really get what you're trying to do.
why don't you just get the original function's result, and add your calculation on its result then ?
|
|
|
|
|
Can ya do a example for me
|
|
|
|
|
nah1337 wrote: Can ya do a example for me
you're kidding, right ?
|
|
|
|
|
No im not see this
I want to redirect/ patch a call of the 10003DD7 function its addres is 0x0003DD7 and calls vsnprintf what addres is 0x0076533
int sub_10003DD7(char *Dest, size_t Count, char *Format, ...)
{
va_list va; // [sp+18h] [bp+10h]@1
int result; // eax@1
size_t v5; // esi@1
char *v6; // edi@1
va_start(va, Format);
v5 = Count;
v6 = Dest;
result = _vsnprintf(Dest, Count, Format, va);
v6[v5 - 1] = 0;
return result;
}
|
|
|
|
|
I think your best bet is to look up Matt Pietreck's various books and articles. He does that soort of thing on a regular basis.
Bram van Kampen
|
|
|
|
|
I know using the CWnd::SetIcon to set the icon for the program executing,
but how to make the exe file use the icon too in the explorer?
It always uses the default ugly MFC icon!
|
|
|
|
|
because you probably modified it, but didn't change every devices of the icon, did you ?
also, a possible error if you didn't modify the default icon but added yours to the project, is because the MFC default icon ID is smaller than your icon in the resource.h file...
check that out
|
|
|
|
|
Windows explorer will choose the first icon in the exe's icon list. So ensure that you icon have the smallest icon id.
1) Now insert your favorite icon to project,
2) edit the resource.h and assign the id of your icon as 128 (id of default MFC icon).
3) If any other Icon id have 128 as id, update them accordingly to avoid conflict. For instance,
#define IDR_MAINFRAME 129
#define IDI_EXE_ICON 128
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|
wasn't it what I say ?
|
|
|
|