|
Thanks for the help ...
Prem Kumar wrote:
this may change if you change the sequence of the actions when
testing or debugging.
Is that meaning I have to do exactly the same operations when Debbugging (press same buttons in same order in my app ?) ...
~RaGE();
|
|
|
|
|
You got it! you have to have the same sequence.
|
|
|
|
|
Well, OK. I have implemented Chris´ macros too (supposed to show info about the line where not freed memory is overwritten), but it did not change anything in the debug output, and i cannot spot where something wrong occurs ... any idea how to do that ? (Problem is, i have to take over the bugged code from somebody else =/)
~RaGE();
|
|
|
|
|
Hi,
Check your code that you are properly freeing up Map
at your app exit.
|
|
|
|
|
I've tried all of the macros too and they didn't work. I finally did what was suggested, buy Bounds Checker, after wasting 8 hours trying to get VC++ to show me line number and filename of leak.
As an aside the 40+ leaks identified from the C++ runtime library (STL's list, vector and iostream calls) weren't really leaks. Turns out I just needed to link a library (MFC42D.LIB) in to get rid of those reported leaks.
|
|
|
|
|
How do i release the memory after reading from the CList from the head position.If i run the folowing code i get Debug assertion failed at the delete statement.
void CPLayerApp::LockIt()
{
unsigned char data[10], mCnt,mMid;
CMessage* pMess;
CSingleLock singleLock(&m_SyncLock.m_mutex);
CString str="";
while(1)
{
if(m_messList.GetCount() != 0)
{
singleLock.Lock();
pMess = &m_messList.GetAt(m_messList.GetHeadPosition());//m_messList is a CList pointer
mCnt = pMess->m_cnt;
mMid = pMess->m_mid;
pMess->GetData(data);
POSITION pos = m_messList.GetHeadPosition();
m_messList.RemoveHead();
delete pos;
singleLock.Unlock();
if(data[0] == 0x10)
{
str.Format("%0x",data[0]);
AfxMessageBox(str);
break;
}
}
Sleep(200);
}
Rsh
|
|
|
|
|
I do not see the point of your code Why using a POSITION if you delete it two lines after ?
~RaGE();
|
|
|
|
|
Actually the statement of 'delete pos' doesnt make sense !!
pos is just a stack variable and its value is not necessarily
a pointer.
|
|
|
|
|
Ok. If POSITION and pos r not required can u pls. suggest how to release the memory associated with the element in the CList after you read that? Cause RemoveHead()is not doing that.
Rsh
|
|
|
|
|
how abt 'delete pMess' ???
|
|
|
|
|
No Prem,
even that doesn't work.Just now i tried with that also. Its giving the same error.
Rsh
|
|
|
|
|
As far as I know (but I may be wrong) if you delete an Item with RemoveHead(), itreturns a pointer on the deleted item. So let´s use this to delete the already-deleted-in-the-list Item ... no ?
~RaGE();
|
|
|
|
|
Are you just trying to iterate through the list? If so, there are easier ways, I will elaborate if needed.
Otherwise, just remove the line that says 'delete pos;'. As was stated this is a variable declared on the stack. Trying to delete it will cause debug assertion errors. (Worse yet in release mode)
|
|
|
|
|
what exactly i want is, to read the elemnts from the headposition in Clist and immediately after reading,would like to delete the already read element from the list & also release the memory that was associated with the deleted element.
Can anybody pls. elaborate on this
The code is as follows
void CPLayerApp::LockIt()
{
unsigned char data[10],mCnt,mMid;
unsigned char *ptr;
CMessage* pMess;
CMessage* delMess;
CSingleLock singleLock(&m_SyncLock.m_mutex);
CString str="";
while(1)
{
if(m_messList.GetCount() != 0)
{
singleLock.Lock();
pMess = &m_messList.GetAt(m_messList.GetHeadPosition());
mCnt = pMess->m_cnt;
mMid = pMess->m_mid;
pMess->GetData(data);
//POSITION pos = m_messList.GetHeadPosition();
m_messList.RemoveHead();
delMess= &m_messList.RemoveHead();
//pMess=(CMessage*)m_messList.RemoveHead();
delete delMess;
singleLock.Unlock();
if(data[0] == 0x10)
{
str.Format("%0x",data[0]);
AfxMessageBox(str);
break;
}
}
Sleep(200);
}
Rsh
|
|
|
|
|
hi, anyone can help me?
I have a MDI app, now need to make all the CMDIchildWnd windows floating outsite the MDI frame, like a dialog. i tried to call SetParent(CWnd::GetDesktopWindow()). it seens work, but bring me two new issues: the child window get a icon in task bar, and it crash when i tried to resize or close it, the error exist in CMDIChildWnd::GetMDIFrame(). what is going on? does CMDIChildWnd limit its parent to CMDIFrameWnd?
Any proficients can help me? thanks a lot.
->
|
|
|
|
|
I find that by creating a new frame and loading it wil the OnNew() event works. Its not a child frame in the true sense but it loads in a new external window. However I do not know if this is what u want.
"If at first you don't succeed.....you must be installing Windows..."
Windoze CP - Windows without the cr*p (Now with automatic bug eliminator!)
Hey so what if I'm a geek! Byte me!
|
|
|
|
|
sorry, Jonny. i didn't catch your mean. "not a child frame in the true sense but it loads in a new external window"?
|
|
|
|
|
Write a new cpp file with a new Window in it. Then call it from the OnNew() function with ShowWindow()
"If at first you don't succeed.....you must be installing Windows..."
Windoze CP - Windows without the cr*p (Now with automatic bug eliminator!)
Hey so what if I'm a geek! Byte me!
|
|
|
|
|
A VARIANT which is an array of VARIANT's, surely ?
If you have 50-60 global variables, you're bound to burn in hell anyhow. Globals are rarely necessary, almost always a bad design, and 50-60 is just an incredible achievement IMO.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
If you have 50-60 global variables, you're bound to burn in hell anyhow
I hear you
It is Illogical to define an inventor by his invention
|
|
|
|
|
Create a new ATL object and add properties to the object that return the global variables.
It's probably the easiest way to do it, although it is a bit of a hack.
Michael
"Eureka" is Greek for "This bath is too hot"
|
|
|
|
|
Michael P Butler wrote:
Create a new ATL object and add properties to the object that return the global variables.
An ATL object with 60 properties sounds bad to me!
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
It's not many more than your standard ActiveX control. You could even just use methods with multiple out parameters.
Good to see you back Nish.
Michael
"Eureka" is Greek for "This bath is too hot"
|
|
|
|
|
Michael P Butler wrote:
It's not many more than your standard ActiveX control
But those properties are set at design time, aren't they? And I doubt if it is advisable either! Anyhow, I might be wrong! My COM awareness is still pretty raw, despite Mike Dunn's noble attempts via Sonork
Michael P Butler wrote:
Good to see you back Nish.
I was never gone, was I? I was hoping my soul would still hang around here
Author of the romantic comedy
Summer Love and Some more Cricket [New Win]
|
|
|
|
|
Nishant S wrote:
But those properties are set at design time, aren't they?
Properties can be set at run time or at design time. You can specify properties to be get only, so you can't set them at all. A property is just a wrapped method really.
Nishant S wrote:
I was never gone, was I? I was hoping my soul would still hang around here
You hadn't posted for a while, so I assumed you had taken a break. Although a browse of the forums shows you've been here, just not been as prolific with your postings.
Michael
"Eureka" is Greek for "This bath is too hot"
|
|
|
|