|
kakan wrote: Allocated memory is filled with nulls in debug mode
whats the reason for this difference?
thanks!
|
|
|
|
|
In debug mode, filling uninitialized memory with zero's makes it easier to see that your program has not initialized it.
Software Zen: delete this;
|
|
|
|
|
See Gary R. Wheeler's answer, above.
But this difference in behaviour is a very common source of problems in release mode builds.
|
|
|
|
|
kakan is right, but to complete, just compare the sizes of your two generated (debug and release) exes...
you'll see the difference !
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
In Debug mode, all local variables not explicitly initialized by the program are initialized with 0xCC.
karmendra_js wrote: I started adn finished my project in release mode, how would it be different if it was done in debug mode.
This is backwards. You should develop and test it in Debug mode, and only when all of the bugs have been removed should you compile it in Release mode.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
In debug mode, two things happen.
First, the compiler generates information about your program used by the debugger. The compiler also generates code to initialize memory to default values.
Second, in debug mode you run your programmer under the debugger. The debugger lets you step through your code, examine data as the program executes, set breakpoints, and perform other operations. The purpose of the debugger is to let you run your program in a controlled fashion so that you can see what it is doing as it runs.
In release mode, the compiler doesn't initialize memory for you; it assumes your program will initialize what it needs. As a rule, in release mode the compiler will also 'optimize' your code. In simplest terms, the compiler generates machine code that runs as fast as possible. The machine code in this case looks different from the debug version, since the compiler can rearrange operations in order to improve efficiency.
As someone else has mentioned, you really want to run your program in debug mode first. This lets you get things working in a controlled environment. After it looks like things are working correctly in debug mode, rebuild the program in release mode, and test it again. There are subtle differences between debug and release. The article Debugging Release Mode Problems[^] has more information.
Software Zen: delete this;
|
|
|
|
|
WHENEVER I COPY MY PROJECT TO ANOTHER PLACE AND RENAME IT
CLASSVIEW IS MISSING,AND RESOURCE VIEW BECOME INCAPABLE.
HOW TO OVERCOME THIS PROBLEM? IT WAS NOT HAPPENING EARLIER
BUT NOW IT IS HAPPENING.I CANNOT WORK IN MASTER COPY.
PLEASE HELP
|| ART OF LIVING ||
|
|
|
|
|
Look in the project files and substtitue all absolute paths to the new ones.
And then rebuild all.
|
|
|
|
|
THERE ARE NO ABSOLUTE FILES
AND ABSOLUTE FILES MAY CAUSE PROBLEM FOR BUILD HERE PROJECT IS NOT GETTING LOADED PLEASE TELL ,I HAVE REBUILDED ALL
PROBLEM PERSISTS
|| ART OF LIVING ||
|
|
|
|
|
Make sure you copy the .clw file. This is a text file that contains a list of classes and resources to view in the class view along with some basic information about each class. This file can be edited if you you know the format. I add things to my .clw all the time.
John
|
|
|
|
|
THERE ARE NO ABSOUTE FILE PATHS IN PROJECT.
ANYWAY FILES USED MAY CAUSE PROBLEM WHEN I WILL BUILD OR RUN THE PROJECT HERE PROJECT IS NOT GETTING LOADED
PLEASE SOMEBODY HELP?
|| ART OF LIVING ||
|
|
|
|
|
OK. I have seen this happen when some of the project files are write protected (Read Only).
Could that be the reason of your problems?
|
|
|
|
|
did you remember to also copy the res subdirectory?
Steve
|
|
|
|
|
MAN I AM COPYING ENTIRE PROJECT FOLDER
|| ART OF LIVING ||
|
|
|
|
|
If you have the same project open in two instances of Visual Studio then the second does not show the class view.
Oh, please get rid the caps lock!
Elaine
The tigress is here
|
|
|
|
|
I am not opening same project.
My problem is still unsolved
|| ART OF LIVING ||
-- modified at 23:34 Friday 28th October, 2005
|
|
|
|
|
Hello,
I have a problem I don't know how to fix
I've got some code that works perfectly in the main executable, but falls over if moved to a dll
Heres some code written to highlight the problem:
The first example works perfectly:
The method setString sets sMyString to “happy string” and everything works just dandy
#include "LocalStringRefTest.h"
#include <string>
#include <stdio.h>
using namespace std ;
int main(int argc, char* argv[])
{
{
string sMyString;
sMyString = "";
{
LocalStringRefTest tester;
tester.setString(sMyString);
}
printf (sMyString.c_str());
}
return 0; }
But if I move my class to a dll and try again,
Everything works just fine until sMyString goes out of scope
#include "myDll/StringRefTest.h"
#include <string>
#include <stdio.h>
using namespace std ;
int main(int argc, char* argv[])
{
{
string sMyString;
sMyString = "";
{
StringRefTest tester;
tester.setString(sMyString);
}
printf (sMyString.c_str());
}
return 0; }
In same executable
LocalStringRefTest.h
#ifndef LocalStringRefTest_CLASS_H
#define LocalStringRefTest_CLASS_H
#include <string>
using namespace std ;
class LocalStringRefTest
{
public:
LocalStringRefTest();
bool setString(string& sString);
protected:
string m_sString;
};
#endif
LocalStringRefTest.cpp
#include "LocalStringRefTest.h"
using namespace std ;
LocalStringRefTest::LocalStringRefTest()
:m_sString("Happy String")
{
}
bool LocalStringRefTest::setString(string& sString)
{
sString = m_sString;
return true;
}
In dll
StringRefTest.h
#ifndef StringRefTest_CLASS_H
#define StringRefTest_CLASS_H
#include <string>
using namespace std ;
class __declspec(dllexport) StringRefTest
{
public:
StringRefTest();
bool setString(string& sString);
protected:
string m_sString;
};
#endif
StringRefTest.cpp
#include "myDll/StringRefTest.h"
using namespace std ;
StringRefTest::StringRefTest()
:m_sString("Happy String")
{
}
bool StringRefTest::setString(string& sString)
{
sString = m_sString;
return true;
}
As i debug through my code, everything works fine until the string goes out of scope
when that happens i get:
NTDLL! 7c96cd80()
NTDLL! 7c960af8()
KERNEL32! 7c85e7af()
_CrtIsValidHeapPointer(const void * 0x00961a00) line 1606
_free_dbg_lk(void * 0x00961a00, int 1) line 1011 + 9 bytes
_free_dbg(void * 0x00961a00, int 1) line 970 + 13 bytes
free(void * 0x00961a00) line 926 + 11 bytes
operator delete(void * 0x00961a00) line 7 + 9 bytes
std::allocator<char>::deallocate(void * 0x00961a00, unsigned int 33) line 64 + 38 bytes
std::basic_string<char,std::char_traits<char>,std::allocator<char>
::_Tidy(unsigned char 1) line 592
std::basic_string<char,std::char_traits<char>,std::allocator<char>
::~basic_string<char,std::char_traits<char>,std::allocator<char> >()
line 59 + 39 bytes
main(int 1, char * * 0x00a70eb0) line 26
mainCRTStartup() line 206 + 25 bytes
KERNEL32! 7c816d4f()
Invalid Address specified to RtlValidateHeap( 00A60000, 009619E0 )
from looking around on the net it seems this is a fairly commonly encountered problem.
I've found a lot of useful information but not a specific answer i was able to use to resolve my problem
i've found the related article on http://support.microsoft.com/kb/168958/
but i just don't understand what i need to do to be able to make it work,
thanks for you help,
mat
|
|
|
|
|
Hello. Im not 100% sure, but I think your problem is StringRefTest.cpp
bool StringRefTest::setString(string& sString){
sString = m_sString;
return true;
}
Shouldn't the assignment be the other way around?
Now, you have a local string and you assign it to sString.
That means that you allocate the string in the dll and frees it in your main program. And that's a no no.
|
|
|
|
|
the assignment is the right way around
perhaps i could have called the method getString to avoid confusion.
|
|
|
|
|
It would have made things clearer...
But still, I suspect the assignment. What does the copy constructor look like?
Maybe you could try to copy just the string data instead of the complete string class in the dll?
But again, I'm not 100% sure about this.
|
|
|
|
|
Do the CRT runtimes (Project Properties->C/C++->Runtime Library) of the exe and dll match?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Thank you Senthil,
That sounds like a useful sugestion,
but i can't find the properties you're refering to in vc++ 6.0.
can you please explain how i get to the runtime library property?
-- modified at 4:00 Friday 28th October, 2005
oh i've found it, but the dll uses
'multi-threaded dll'
i can get my code to work by using the same runtime,
but wouldn't that be the wrong runtime to use for my executable?
cheers
mathew
|
|
|
|
|
I would like to know how to make a button which can toggle its button status.
When you press it, it will down and remain unchange until you press it again.
Please help!
Alex
|
|
|
|
|
Isn't there a property in the designer to turn this on ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I would like to know it.
If you know, please tell me.
|
|
|
|