|
I get the following Memory Leaks warning when my Dialog MCF program ends.
Detected memory leaks!
Dumping objects ->
c:\hctsemu\emulation\exampledlg.cpp(1648) : {644378} client block at 0x013A0A70, subtype c0, 404 bytes long.
a CSigDlg object at $013A0A70, 404 bytes long
Object dump complete.
The program '[3732] Example.exe: Native' has exited with code 20 (0x14).
This is using the following code to provide details:-
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
#include ".\ssic_exampledlg.h"
Can any experts out there help me to home in on the memory leak please.
Graham.
grahamfff
|
|
|
|
|
Find out where this CSigDlg object was created and where it should have been destroyed.
The easiest way is to set breakpoints to the constructor and destructor of CSigDlg.
Don't try it, just do it!
|
|
|
|
|
Grahamfff wrote:
c:\hctsemu\emulation\exampledlg.cpp(1648) : {644378} client block at 0x013A0A70, subtype c0, 404 bytes long.
what is the code at that line ?
is there a malloc or new or something else there ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
So what is at line 1648 of exampledlg.cpp?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I have written a program with Visual C++. Where on this website can I look for articles that inform me of how to create a skin for the executable file? Where can I find articles that will inform me of how to create the dialogue box which will give the user the option of saving, printing output?
|
|
|
|
|
On that page...
Don't try it, just do it!
|
|
|
|
|
C++/MFC Articles just look through them and pick what you like...
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
try using the CFileDialog class.....u can use it for saving and opening files.....already defined browser for that.....
search for it in MSDN...
HOPE THAT HELPZ....
cheerz.....
"faith, hope, love remain, these three.....; but the greatest of these is love" -1 Corinthians 13:13
|
|
|
|
|
I found this article and sample source ...
http://www.codeproject.com/dialog/skinsyse.asp
Very useful when I wrote my first skinned app.
I had to extended the functionality a lot to accomodate all the
features I eventually required but it was a great starting point.
You simply derive your main dialog class from the SkinDialog
class provided in the article.
Steve T
|
|
|
|
|
class CBasic {
private:
int x;
CRect rect;
CPoint pt;
public:
void function_1();
void function_2();
};
void CBasic::function_1(){
x = 5;
rect = CRect(1, 2, 3, 4);
pt.x = 1;
pt.y = 2;
cout << x << rect.bottom << pt.y; // 5, 4, 2
}
void CBasic::function_2(){
cout << x << rect.bottom << pt.y; // 5, 0, 0
}
What the heck? Shouldn't CRect and CPoint retain the value?
|
|
|
|
|
Ooops forgot to mention
function_1 is called first then function_2
void CBasic::function_1(){
x = 5;
rect = CRect(1, 2, 3, 4);
pt.x = 1;
pt.y = 2;
cout << x << rect.bottom << pt.y; // 5, 4, 2
function_2();
}
|
|
|
|
|
Strange as this code worked fine for me (i.e., both produced 542). I wonder if it could be a buffering problem (as I see your edited post, this is most likely the problem). Try calling function_2() first and note the result. Also try putting an endl at the end of each cout statement.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
You are right it does work. I tried in a clean Doc/View program too.
Odd that it doesn't work in the current program I am working on.
I have OnDraw calling a function to draw but CRect and CPoint value just disappear. I even output the value before the function is called but as soon it's called the value is gone.
This is what happen I use Debug to trace into it
CXX0069: Error: variable needs stack frame
|
|
|
|
|
Are you using cout in a GUI application?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Ooops disregard the debug error message. I breakpoint too early.
No cout I am drawing a graph and basically I have it
CPoint pt declare in the View header
int dummy declare in the header also
OnDraw(CDC* pDC){
CRect final;
int x =6, y = 7;
pt = (3, 2);
dummy = 9;
// At this point 3, 2 is still valid
final = function(x, y);
// pt, 3, 2 returns
// Draw final rectangle
}
CRect function{int x, int y){
// pt x = 0, y = 0;
// dummy = 7
CRect temp;
temp = (CPoint(pt.x+x, pt.y+y), CSize(3,3));
return temp;
}
Something like that. I don't understand why my function is having problem accessing pt value but if I declare it as int it would be fine Grrr. pt.x was orignally an int and it worked fine but when I changed it to CPoint pt.x it stopped working.
|
|
|
|
|
Anonymous wrote:
pt = (3, 2);
Are you sure this is right? Set a breakpoint on this statement and notice that the x and y member variables are not what you think they should be. Use an explicit assignment, or use something like:
pt = (2 << 16) + 3; Anonymous wrote:
CRect function{int x, int y){
Is this a member of the view class? In either case, the left curly brace does not match the right parenthesis.
Anonymous wrote:
temp = (CPoint(pt.x+x, pt.y+y), CSize(3,3));
This assignment also looks suspect. I would change it to this instead:
CRect temp(CPoint(pt.x+x, pt.y+y), CSize(3,3));
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
I just check the memory address.
When I called rect/pt value in the function it reads a new memory address location?!? And it doesn't do that with int.
The View contructor was only called once.
|
|
|
|
|
Disregard. I figured out why. I feel very stupid right now
When I chaged declaration to header, I forgot to clear the declaration in the function(I thought I did).
I am surprise the compiler didn't raise flag about the overlap. Hmm I remember there was a declaring function to tell the program which overlap variable to use.
|
|
|
|
|
I am getting these linking errors. i would appreciate if someone has already had these errors and let me know how he or she resolved them.
Linking...
LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/FORCE' specification
Creating library ..\mmig\m3.lib and object ..\mmig\m3.exp
vld.lib(vld.obj) : error LNK2019: unresolved external symbol __CrtDbgReport referenced in function "public: __thiscall VisualLeakDetector::VisualLeakDetector(void)" (??0VisualLeakDetector@@QAE@XZ)
vld.lib(vld.obj) : error LNK2019: unresolved external symbol __CrtSetAllocHook referenced in function "public: __thiscall VisualLeakDetector::VisualLeakDetector(void)" (??0VisualLeakDetector@@QAE@XZ)
vld.lib(vld.obj) : error LNK2019: unresolved external symbol "void __cdecl std::_Xran(void)" (?_Xran@std@@YAXXZ) referenced in function "private: class std::basic_string,class std::allocator > __thiscall VisualLeakDetector::buildsymbolsearchpath(void)" (?buildsymbolsearchpath@VisualLeakDetector@@AAE?AV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ)
vld.lib(vld.obj) : error LNK2019: unresolved external symbol "void __cdecl std::_Xlen(void)" (?_Xlen@std@@YAXXZ) referenced in function "private: void __thiscall VisualLeakDetector::reportleaks(void)" (?reportleaks@VisualLeakDetector@@AAEXXZ)
..\mmig\m3.dll : fatal error LNK1120: 4 unresolved externals
Jay
|
|
|
|
|
|
How to display ohm sign, 'Ω', on the screen using VC++, VC++ .net and VB.net? if possible?, What is the project setting?
|
|
|
|
|
ds feng wrote:
How to display ohm sign, 'Ω', on the screen...
Is this a console or a GUI application?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
The console does not support it, and a GUI application will need unicode for that sign because the ANSI converts it to 0x4F and that is 'O'.
Don't try it, just do it!
|
|
|
|
|
Why did you delete your answer??
The unicode data for L"Ω" is 0xA9 0x03 0x00 0x00.
=> WORD wOhm = 0x03A9;
Don't try it, just do it!
|
|
|
|
|
Hi ds feng,
#ifndef UNICODE
#define UNICODE
#ifdef UNICODE
//ur code for display ohm goes here
#endif
This might solve your problem.
Cheers,
Vishal
|
|
|
|