|
I'm facing a situation where it appears from tracing in my application that an attempt to allocate memory via C++ new is failing, natually only at the customer, and there only if the allocation is large. Every failure instance I've seen involves sizes just beyond 4K (say 4100 - 4400 bytes). Otherwise no problem.
Really scratching my head looking for a good next step in either diagnosis or adjustment / repair.
AJ
|
|
|
|
|
thats just over a page size isnt it?
anything wrong with the virtual memory settings?
"there is no spoon" biz stuff about me
|
|
|
|
|
Yes it is, but I'm drawing a blank on what virtual memory setting would function as an upper limit on a heap allocation request. (And also why the new would fail so catastrophically)
AJ
|
|
|
|
|
4K is not what I would call large by any means. Are you new'ing a large number of objects?
I can't recall ever seeing new fail. Maybe you've screwed the heap. A Debug Build with CRT Heap checking enabled may help.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
I wouldn't think 4K would be bad either. It is a single new, which allocates varying amount depending on amount of data attached to a print request. I can't say that I've got enough instances yet to prove 4K is a hard limit. And I've never seen a new fail this way either. Is the heap screwed? May very well be, but not on our systems running with the same program levels and even print data. Help in figuring out why it's screwed is part of why I turned here. I'll see what I can do with your suggestion. Thanks
AJ
|
|
|
|
|
The problem probably isn't where you think it is. Normaly when this type of error occurs it is because of a miscalulation which eventualy caused a memory overwrite that occured some time earlier in the program. Therefore, you need to look backwards at what happen before you made the allocation, it most likely occured in some other function usualy one that was called from the current function or one of the functions up the line that eventualy called the function where the failure. One way that might help track down the problem (that I have used) is to use TRACE, in all realated function (nomaly same class) to show every allocation/deletion and read/write invold. For an example of what I am talking about download a CDibData (@codeproject), it contains code for doing this type of tracking. I had the same problem when I wrote that code (and others) and did not bother to remove the tracing (yet!).
Well, I hope this helps!
Good luck!
INTP
|
|
|
|
|
Thats right that the problem is almost definately not where you think it is.
I mean look at the definiton of new.
void* __cdecl operator new(size_t nSize)
{
void* pResult;
#ifdef _AFXDLL
_PNH pfnNewHandler = _pfnUninitialized;
#endif
for (;;)
{
#if !defined(_AFX_NO_DEBUG_CRT) && defined(_DEBUG)
pResult = _malloc_dbg(nSize, _NORMAL_BLOCK, NULL, 0);
#else
pResult = malloc(nSize);
#endif
if (pResult != NULL)
return pResult;
#ifdef _AFXDLL
if (pfnNewHandler == _pfnUninitialized)
{
AFX_MODULE_THREAD_STATE* pState = AfxGetModuleThreadState();
pfnNewHandler = pState->m_pfnNewHandler;
}
if (pfnNewHandler == NULL || (*pfnNewHandler)(nSize) == 0)
break;
#else
if (_afxNewHandler == NULL || (*_afxNewHandler)(nSize) == 0)
break;
#endif
}
return pResult;
}
Look at the for(;;)
It should not fail.
You have corrupted the heap.
Get MMGR from http://www.fluidstudios.com/publications.html .
It is an excellent class.
Ensure that you carefully read the instructions [ especially the order of includes].
Use it on Debug and Release builds.
Check that you have not used new and free or similar.
Check for resource leaks.
Regards,
axe
|
|
|
|
|
You will have to forgive me for getting some of the terminolgy wrong or asking what may seem like a newbie question.
I've got years and years of programming experience, mostly C and mostly embedded, so I don't write a lot from scratch for the PC environment. But give me any existing code in almost any language, and I fix items or add new features.
So, I just got into the Home Theater PC scene, bought an LCD display for the case, and now am a beta tester for the control software that drives the LCD. The company just recenly released to the beta testers C++ code that implements a plug in via a DLL to their software. Fine, no problem.
Using Visual Studio .Net 2003 I have successfully made three additional plug is to "expose" different information to the LCD control software, i.e. an example would be going to a Web Server and getting weather information to display.
Well, now I want to display information from S.M.A.R.T. hard drives. I found a publicly available .DLL that uses the COM architecture. Took a little bit of time figuring out how to invoke this in .Net, but I got it working. In fact, it's very cool how you just add a reference and it builds an "Interop::xxx" wrapper for you. Then you can just create an instance of the class, and off you go.
So having implemented and tested my logic for getting the data I wanted from the COM DLL, I then went about and created a new project for the DLL planning to cut and paste my logic with appropriate adjustments into my MFC DLL. Wrong!
I've done tons of searches and tried all different ways, but I'm not even close to getting this working. So my question is can someone point me in the right direction or post some sample code? It seems to me that I need a .h file or something that describes the interfaces. And even if I get a pointer to the interface, how do I get the structures that the interfaces are passing back? It seemed like it was going to be such a piece of cake the way the .Net worked.
Any and all help would be appreciated. I can also post or email the zipped project and DLL if it would be helpful.
Charlie
|
|
|
|
|
Found solution, and have working. Needed #import directive, gave me access to interface and methods.
Charlie
|
|
|
|
|
Hello,
I have noticed that whenever I exit my VC++ MFC app a msg appears in the Debug tab. The message is (in bold):
.
:
.
Loaded 'C:\WINDOWS\system32\uxtheme.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\MSCTF.dll', no matching symbolic information found.
Loaded 'C:\WINDOWS\system32\mslbui.dll', no matching symbolic information found.
The thread 0xB8 has exited with code 0 (0x0).
Detected memory leaks!
Dumping objects ->
strcore.cpp(118) : {52842} normal block at 0x00C49118, 14 bytes long.
Data: < . > 01 00 00 00 01 00 00 00 01 00 00 00 2E 00
.
:
.
Can someone tell me if it is normal for this to happen in Debug mode?
dNimrod#X
________________________
|
|
|
|
|
No, it is not normal. You have a new without a matching delete .
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
DavidCrow wrote:
You have a new without a matching delete.
I thought so... Thanks a lot for the reply.
dNimrod#X
________________________
|
|
|
|
|
Does anyone know what are the possible return values for the LowLevelKeyboardProc hook procedure?
I have been trying to find some resources in my MSDN Library but couldn't as hooks are not that so well documented.
All help is much appreciated.
Also: in which header is WH_KEYBOARD_LL defined? Again both the MSDN library and Microsoft's site state it is defined in Winuser.h but I still get a "not defined error" whenever I try to compile.
dNimrod#X
________________________
|
|
|
|
|
I was using the connection string supplied in this site under the heading 'ado connection strings' and it works fine when using the CDatabase class. However the CDatabase class is very slow for what I want to do and I'd like to use the odbc api. I'm trying to make a connection like I did with the database object except using SQLConnect. I can't seem to get it to work, any suggestions would be very appreciated. Here's what I have so far:
"Driver={Microsoft dBASE Driver (*.dbf)};DriverID=533;Dbq=c:\dbasetables\;"
that's what the connection string looks like when it's finished.
I've used this same code in another project to connect to a datasource (sql server), but I can't get this to work. Thanks in advance!!;)
If it's broken, I probably did it
bdiamond
|
|
|
|
|
Verify that you have the driver name exactly right. I think it is dBase instead of dBASE. Also, shouldn't you be using double backslashes?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I changed the dBASE to dBase, and it still doesn't work. actual string is returned from CFileDialog as to where they wanna put the .dbf file at, so that's what it actually looks like after it's formatted already. I just put it in like that for clarity.
BTW: thanks for your help the other day on 'public member not working';)
If it's broken, I probably did it
bdiamond
|
|
|
|
|
bdiamond wrote:
BTW: thanks for your help the other day on 'public member not working'
You're welcome, even though I did not provide you with any help. You seemed to have fixed it on your own accord.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I just now set up my odbc error handling and it's telling me that I specified an invalid string or buffer length. I had always used SQL_NTS before, and now I've tried 512 which is how big I specified the character arrays, and still no luck.
If it's broken, I probably did it
bdiamond
|
|
|
|
|
How about a small code snippet, that includes the call to SQLConnect() ?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I don't know if this is only ofr Logitech, but I want to GET/SET the mouse direction settings, which can be calibrated using Windows's Mouse Config Panel (well, if you have WinXP, I guess you need Logitech's MouseWare).
Is that possible?
|
|
|
|
|
Hi all!
I'm trying to build a Visual C++ application (a dialog application in Release mode with a simple window that creates a new thread in CWindowDlg). It compiles but in link I get this error:
<br />
LINK : fatal error LNK1561: entry point must be defined<br />
NMAKE : fatal error U1077: 'link.exe' : return code '0x619'<br />
Does anybody know what it means and how I could eliminate it?
Thank you in advance!
|
|
|
|
|
IT sounds like you either don't have a CWinApp class defined (e.g., somewhere you need the line: CMyWinAppDerievdClass theApp; )
Or your your project settings are incorrect and you aren't set to run an MFC project or something.
Remember, even if you win the rat race, you're still a rat.
|
|
|
|
|
Well, I have in my code the line
CWindowApp theApp;
and I have "Use MFC in a shared DLL" so I don't know but I think they are not the problem...
Usually, I can compile and link with no problem, but when I try to create threads then I got this problems in link.
Any idea?
Thanks!
|
|
|
|
|
Are you using the /ENTRY option with the linker?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Where should I write down this option, please?
Thank you.
|
|
|
|