|
In Visual Studio, you can get some elementary memory leak tracking using your Debug build. When you finish running your program in the debugger, check out the "Debug" output window. At the bottom, if you have memory leaks, it should spew out a whole pile of stuff looking like:
Detected memory leaks!
Dumping objects ->
{23103} normal block at 0x017C96D0, 36 bytes long.
Data: < > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
{23102} normal block at 0x017C97B0, 216 bytes long.
Data: < > FF FF FF FF FF FF FF FF 00 00 00 00 00 00 00 00
Object dump complete.
That means you've got memory leaks. To find out where they're occurring, you can double-click on them and Visual Studio *may* take you to the "new" statement that caused the problem. If not, I recommend you to a search on _crtBreakAlloc for a bit more info on how to track down the problems.
Other than that, if you're willing to pay money (and quite a bit, I think) you can use BoundsChecker (just search CP for it - it gets mentioned all the time).
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
ah, thank you for the help
Kuniva
|
|
|
|
|
I am trying to create a MFC dialog app that has a small amout of DX but I don't really know Win32 that well and all the examples are in win32 SDI window. Does anyone have any examples?
-Matt Newman
-Matt Newman
-Sonork ID: 100.11179:BestSnowman
|
|
|
|
|
Will somebody clear this up for me? Are they the
same?
And if so, are all future Visual C++ platforms going to
produce MISL code which would need a run-time
machine to interpret(yuck)?
|
|
|
|
|
I am not really sure but I think that you can choose to compile Managed (.Net) or Unmanaged code.
-Matt Newman
-Matt Newman
-Sonork ID: 100.11179:BestSnowman
|
|
|
|
|
lol
Kuniva
Want, take, have.
(oh btw, best way of learning some language is by looking at examples, start large!) :p
|
|
|
|
|
Satheesh Venkatesan wrote:
Will somebody clear this up for me? Are they the
same?
VC.NET is just a marketing name for VC 7.0
Satheesh Venkatesan wrote:
are all future Visual C++ platforms going to
produce MISL code which would need a run-time
machine to interpret(yuck)?
It is a matter of choice. You can compile your VC++ applications as managed (MISL) or unmanaged (native code). I pretty much believe that VC++ developers will continue to use the unmanaged mode, except for the interop with managed applications.
I vote pro drink
|
|
|
|
|
Is there any way to play MPEG file in VFW (Video for Windows)?
Jerzy
|
|
|
|
|
I need to feed a CString into a LPSTR. First, I simply assigned a CString to the LPSTR item like so:
lvitem.pszText = File.GetFileName ();
compiler error:
“no operator defined which takes a right-hand operand of type 'class CString'”
I then try typecasting it to a LPSTR…
lvitem.pszText = (LPSTR) File.GetFileName ();
complier error:
“cannot convert from 'class CString' to 'char *'”
Looking at CString’s methods, I see it can be typecast to a LPCSTR but not a LPSTR. So I try this:
lvitem.pszText = (LPCSTR) File.GetFileName ();
complier error:
“cannot convert from 'const char *' to 'char *''”
Ok, finally I typecast to LPCSTR then to a LPSTR. It compiles but the string is garbage.
lvitem.pszText = (LPSTR) (LPCSTR) File.GetFileName ();
Blah. I am new to MFC, but I can’t help but feel this a too much drama for a simple string .
Thx for any help.
|
|
|
|
|
The typical way to convert a CString to a LPSTR is to use CString::GetBuffer(...) and CString::ReleaseBuffer(...) which protect the CString from being mangled by the code playing with the LPSTR. Be sure to read the help for the CString overview and the functions just mentioned to see why. If your code doesn't modify the text, then it's often better to assign the CString to a LPCSTR variable, and then the compiler doesn't complain.
Another thing to keep in mind is that CString will try to keep just one copy of a piece of text when multiple CString's hold the same text. Using GetBuffer and ReleaseBuffer allow the CString to make a local copy of the text so that changing it via an LPSTR won't change the text of all the other CString's. (Which could be a bad thing.)
Dave Goodman
dgoodman@infoway.com
www.dkgoodman.com
|
|
|
|
|
|
The way to do this really depends on what you are trying to do. It looks
like you are trying to put the contents of a CString into a structure. You
may be best off making a copy of the string, and then deleting it
when you are finished using your strucutre. E.g.,
lvitem.pszText = new TCHAR[File.GetFileName().GetLength()];
strcpy(lvitem.pszText, File.GetFileName());
...
delete [] lvitem.pszText;
This is probably the safest way to do it, although it does mean
you create more memory for the string.
If you need an LPTSTR for, say, one function call, you can
use GetBuffer() to get the LPTSTR, and then ReleaseBuffer() after
you're finished.
It can be unsafe to cast a CString like this:
(LPTSTR)(LPCTSTR)someString
.. becuase if the contents of the LPTSTR are changed,
you can run into all kinds of nastiness (believe me, I know from experience. )
The early bird may get the worm, but the second mouse gets the cheese.
|
|
|
|
|
How can I access/use the Add User Dialog on NT 4? I've built my own, however it is slow...
Thanks,
ed
'Love is an obsessive delusion that is cured by marriage.' Dr. Karl Bowman
|
|
|
|
|
I was just wondering if someone could tell me how to put a background image on my C++ form for the time card I just made.
|
|
|
|
|
If by "C++ form" you mean a CDialog or CFormView based window, then this post of mine shows how to set a bitmap as the background for your window.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, I appreciate it!!
|
|
|
|
|
I'm really new to programming, so please bear with me. The first two lines in the code you gave is: "CBitmap m_bitmap_background; BITMAP m_bmInfo_background;" Does this mean I have to right click on the DLG file in class view and add a member variable? What type would I use? I appreciate your help.
|
|
|
|
|
I'm really new to programming, so please bear with me.
Glad to be helpful I'll give you as thorough an explanation as I can (forgive me if some details are already obvious to you).
Well, There's four steps in getting the process done:- Have a bitmap loaded in your resources. I'm assuming the identifier of the bitmap is
IDB_BACKGROUND but you can change it to whatever pleases you most.
- Add the two variables
m_bitmap_background and m_bmInfo_background . The way to do it you suggest is just fine (types are CBitmap and BITMAP , respectively). You can also edit by hand the .h and insert directly the variables.
- Locate the
OnInitDialog of your dialog and insert the stuff where m_bitmap_background and m_bmInfo_background are set their values.
- Go to the class wizard (CTRL+W on most IDE installations) and add a message handler for
WM_ERASEBKGND . This gets you the OnEraseBkgnd method where you can insert the remaining piece of code. Good luck and welcome to MFC programming!
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I went to the class wizard and there is no WM_ERASEBKGND. I saw all the other choices and nothing to do with the background was there. Am I doing something wrong?
|
|
|
|
|
Oh, well, you've got to change the message filter so that WM_ERASEBKGND appears. I don't have the IDE handy, but you should go to the last tab in the class wizard dialog, look for a combo called "message filter" or something like that and select "Topmost frame".
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks, I really appreciate all your help!
|
|
|
|
|
Is there any support within Visual C++ to data structure Graph (not Graphics)?
If not, does anyone know where I can find the resource related to it?
Thanks!
|
|
|
|
|
Boost features the Boost Graph Library, a highly portable (works with MSVC++ 6.0 too) graph library in the spirit of STL. It might seem a little hard to grasp at first, depending on your level of acquaintance with STL.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I am trying to use sockets to communicate between two processes. By default of course there is buffering going on. I need it to be more interactive, as the data being passed is then output to a CView. In certain cases it takes 30 seconds for the first data to show up.
If I look at the TRACE output in the VC IDE I can see that the data is being sent.
I have set the buffer size:
CNe_editorApp *pApp = (CNe_editorApp*) AfxGetApp();
// create socket
if (sock.Create(portnum) == 0) {
TRACE("Could not create socket\n");
::SendMessage(hWnd, UPM_JOBFINISHED, (WPARAM)NULL, (LPARAM)NULL);
return 1;
}
TRACE("Created socket\n");
int buffsize = 10 // bytes;
sock.SetSockOpt(SO_RCVBUF, &buffsize, 4, SOL_SOCKET);
but this hasn't seemed to helped.
Any ideas? Thanks.
Ted
|
|
|
|
|
I'd say buffering has nothing to do with your problem. It rather seems like program #2 is blocking on Receive due to lack of data from program #1, and unblocks after some timeout.
It'd be great if you can post the write and read loops of your two programs to help determine what's going on.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|