|
Inlining absolutely improves performance.
I wrote a program that analyzes satellite switch ring states (we're talking about billions to trillions of possible states here), and inlining improved the algorithm efficiency by 25%.
Turn off incremental linking and "debug and continue", as this injects an additional JMP instruction for every function in your code (a layer of abstraction that makes it easier to patch in new code).
Read everything you can find about the compiler's optimization switches. Some of these are not intuitive, some of them conflict with others. Look at the differences at the assembly language level.
Finally, experience has shown me that I'm hardly ever right about where I think the program is slowing down (and I think I'm a darn good programmer, especially knowing assembly language and being able to root around at that level). Use a code profiler or add profiling in to your code yourself!
Marc
|
|
|
|
|
Ok, is the standard heap manager thingy able to cope with a fragmented heap?
An intelligent heap manager might add a performance hit, but be able to deal with a fragmented heap without failing completely.
Do I have to write my own to get this functionality?
Basically, we have an object cache in our code. When memory gets tight, we throw away some of the cached data. At some point in the future, the new operator throws an exception saying no memory available despite us having at least 1.5G available (big machine). Does this make sense?
J
|
|
|
|
|
Heap fragmentation is a problem.
You can help the heap by allocating data of the same size (make your objects the same size).
I use additional heaps for caching data created with CreateHeap API function which I later destroy using DestroyHeap and create a new one. I use it not for objects, but you can overload new/delete operators to work with the additional heap.
Pavel
Sonork 100.15206
|
|
|
|
|
J Hale wrote:
When memory gets tight, we throw away some of the cached data. At some point in the future, the new operator throws an exception saying no memory available despite us having at least 1.5G available (big machine).
Well, if you mean delete/free by 'throwing away some of the cached data' --and-- next allocation request has the size equal or less to size of data thrown away, then your program should be able to allocate memory without problem.
It either a bug in VC heap manager (which calls OS heap functions in Win2K) or problem with your code overwriting heap info blocks.
Tomasz Sowinski -- http://www.shooltz.com
*** Purgamentum init, exit purgamentum ***
|
|
|
|
|
As I have learned in the old days, it is impossible to have a CALLBACK within a class, this because of the "this" pointer. I usually wrote a static version, which redirected to the "real" function.
Now I've come across another way to implement it using Assembly. However, I don't know how to accomplish this, and though I understand Assembly quite well, this is just something I can't work out. (Understanding is something else as doing.)
Sjoerd van Leent
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Look at the CWndProcThunk class accomplishes this in ATL. That should answer your questions for both x86 and Alpha implementations of this.
Good Luck
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
That is a good point, making it compatible for both x86 and Alpha platforms.
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Although your thunk solution seems fine to me, if you're really wanting to pass a non-static member function as a callback, in some cases you can, if in a wildly non-portable manner. In this thread[^] I explain the method.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Well, the problem rests that I want to interact with the Windows API, so I don't think the API let's me do this (though it is a beauty) .
Sjoerd van Leent
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Greetings...
My application createas .ini file to store some data. I have installer which creates a shortcuts to the .exe the Program Files directory and creates two icons in the start menu and in the desktop.
When I run the application through the desktop shortcut, the .ini file is getting created in the Program Files directory which is what I expect. But when I run the application from the Start menu shortcut, the .ini is getting created in the Start Menu diorectory which is causing the .ini file to be also shown in the Start Menu, which I dont want.
In my application I am using the following method which I belive is wrong -
CreateFile ( "Application.ini", ........ );
How can I make sure that the ini is created in the directory of the program and not anywhere ?
Thanks in advance.
Rgds
Ritesh
|
|
|
|
|
Try with ".\\Application.ini" .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It sounds like your two shortcuts are using different 'Start it' folders. (Look at the properties of the shortcuts) You can either make sure that both shortcuts use the same folder, or you can use an absolute path in your program to access the ini file.
as long as I live it will be fine / there's nothing what I can do / the world will die and so do I / so why should I take care 'Take Care' Funker Vogt
|
|
|
|
|
Thanks.
What is the best method to know the directory in which .EXE is being executed ?
Ritesh
|
|
|
|
|
i need to open a file in read-only mode, and can't seem to figure it out.
The same document is opened sometimes in write mode, and I would like to be able to simply toggle the view to readonly /write depending on where i open it from in the interface.
Is there a simple way to do this? I hope I made sense.
Gracias!
BW
The only people for me are the mad ones, the ones who are mad to talk, mad to live, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow roman candles exploding. - Jack Kerouac
|
|
|
|
|
This should work..
CFile File;
if(File.Open("somefile.txt",CFile::modeRead))
{
\\ we are open and in read only
}
else
{
\\ couldn't open it.. do error control
}
|
|
|
|
|
Thanks, but what I need is to open a document/view as readonly. This is being handled by OpenDocumentFile(), right now.
Is there a way, after the view is displayed to switch the mode to readonly?
BW
The only people for me are the mad ones, the ones who are mad to talk, mad to live, mad to be saved, desirous of everything at the same time, the ones who never yawn or say a commonplace thing, but burn, burn, burn like fabulous yellow roman candles exploding. - Jack Kerouac
|
|
|
|
|
Hello, when I create a Installer-Project for my .net
application, installer found a depend on "MFC70d.dll" and
include the dll. Ok, but when I try to install the
application on Win98/2000 installer throw an
exception "Unable to register mfc70d.dll". How can I
solve the problem?
|
|
|
|
|
according to MS, you can't distribute debug DLLs (mfc70d.dll is the debug MFC DLL).
-c
Alcohol is the anesthesia by which we endure the operation of life.
-- George Bernard Shaw
|
|
|
|
|
btw mfc70*.dll is not a to-be-registered-COM-component.
(unlike mfc42.dll).
She's so dirty, she threw a boomerang and it wouldn't even come back.
|
|
|
|
|
Anybody knows ??
[]'s Cris
|
|
|
|
|
The following will color all the text in the rich edit control.
COLORREF textColor = RGB(130,0,0); // Your color
CHARFORMAT cf;
cf.crTextColor = textColor;
cf.dwEffects = 0;
cf.dwMask = CFM_COLOR;
textColor = cf.crTextColor;
SetSel(0,-1);
SetSelectionCharFormat(cf);
|
|
|
|
|
Thanks a lot ...
Atte,
Cris.
|
|
|
|
|
I have a (STL)string variable
str = " Data Data &newdata& &newdata&"
XML does not allow & in its Body for which I need to escape it using "&a m p;"
Now in this string i need to replace all &'s by "&a m p ;" and write to the xml file .
How do i use the STL string replace function ?
Please Help
|
|
|
|
|
this will do something like CString::Replace:
std::string::size_type pos = 0;
while( (pos = s.find(to_find, pos)) != std::string::npos )
{
s.replace( pos, to_find.size(), repl_with );
pos += repl_with.size();
}
(found on google, but i use it in my own stuff)
-c
Alcohol is the anesthesia by which we endure the operation of life.
-- George Bernard Shaw
|
|
|
|
|
I am trying to show the owner of a file so I wrote the code below
void CFileOwnerDlg::OnButton1()
{
UpdateData (TRUE);
PSID ppsidOwner;
PSID ppsidGroup;
PSECURITY_DESCRIPTOR ppSecurityDescriptor;
if (GetNamedSecurityInfo ((LPTSTR)(LPCTSTR)m_strFile,
SE_FILE_OBJECT ,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION,
&ppsidOwner,
&ppsidGroup,
NULL,
NULL,
&ppSecurityDescriptor
) == ERROR_SUCCESS)
{
char Name [2500];
DWORD dwNameSize = 2500;
char DomainName [2500];
DWORD dwDomainNameSize = 2500;
SID_NAME_USE peUse;
if (LookupAccountSid (NULL,
ppsidOwner,
Name,
&dwNameSize,
DomainName,
&dwDomainNameSize,
&peUse) != 0)
{
TRACE ("%s %s\r\n",Name,DomainName);
}
dwNameSize = 2500;
dwDomainNameSize = 2500;
if (LookupAccountSid (NULL,
ppsidGroup,
Name,
&dwNameSize,
DomainName,
&dwDomainNameSize,
&peUse) != 0)
{
TRACE ("%s %s\r\n",Name,DomainName);
}
LocalFree (ppSecurityDescriptor);
}
}
Whatever file path I input the trace always prints "Everyone"
I have searched msdn and it says "Everyone" is a pre configured group. But when I open User Manager administrative tool I can not see this group. Also for the files I have created I see again "Everyone" as the ownder. I think I should see my user name as the file owner instead of "Everyone".
Can someone please show me how to get the owner of a file.
Orcun Colak
|
|
|
|