|
1
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Chris Richardson
|
|
|
|
|
Is it possible by profiler output to gather what probles is ?
I have ActiveX(ATL) in CDialog (MFC)
Visible problems:
Much time to load,
to unload,
(and leak of memory)
Does this ActiveX in -Process ?
(according to Profiler output )
they marked as appartment,
and MFC app I initialized as Appartment-Threaded.
but accidencial cases can happen...
- does I have in-proc case?
To understand output:
I use interface IPictureDisp for direct loading
pictures from CDialog resource to ActiveX.
(code is below)
Profiler - DevPartner 7.1
Made folowing output:
(is it possible to understand where problem is in, by anylizing it?)
thanks you
list ----------------------------------
Method Name,"% in Method","% with Children","Called","Average"
WaitForSingleObject,"10,16","10,16","31я064","55,19"
#6274 (mfc71d.dll),"5,69","11,23","2я627","365,10"
PtAllSet::baseGet,"3,69","6,35","158","3я939,56"
WaitForMultipleObjects,"3,50","3,50","3я677","160,52"
#6849 (mfc71d.dll),"2,53","52,69","24я929","17,11"
OutputDebugStringA,"2,41","2,41","6я807","59,67"
CallWindowProcA,"2,38","26,62","25я311","15,88"
BitBlt,"2,32","2,32","2я630","148,83"
rand,"2,29","2,42","82я220","4,70"
GetMessageA,"2,02","2,75","3я700","91,93"
#7017 (mfc71d.dll),"1,65","27,88","2я956","94,32"
RtlAllocateHeap,"1,63","1,63","86я808","3,17"
PtAllSet::SetFilter,"1,53","2,08","156","1я655,03"
#6045 (mfc71d.dll),"1,53","8,20","18","14я328,79"
PtVArray::Search,"1,47","1,50","1я898","130,91"
recv,"1,42","1,47","843","283,93"
#5954 (mfc71d.dll),"1,36","2,32","6я821","33,51"
PtAdmin::CloseDictionary,"1,24","2,07","3","69я695,58"
SendMessageA,"1,15","10,41","13я858","13,97"
SetDIBitsToDevice,"1,10","1,10","825","224,15"
PtAdmin::OpenDictionary,"1,02","1,98","3","57я179,20"
#1718 (mfc71d.dll),"0,99","1,08","12я802","13,05"
RtlFreeHeap,"0,89","0,89","85я679","1,76"
PtOnDemandSet::baseGet,"0,88","1,71","47","3я148,29"
#7007 (mfc71d.dll),"0,84","19,16","2я311","61,26"
WaitForMultipleObjectsEx,"0,82","0,82","3я600","38,42"
---------------------------------
code of loading Picture into activeX
<br />
<br />
HRESULT PutImage(IPictureDisp* pPicture, int nEntry)<br />
{<br />
m_isChanged = true;<br />
<br />
if (FireOnRequestEdit(DISPID_PICTURE) == S_FALSE)<br />
return S_FALSE;<br />
m_spPictures[nEntry] = 0;<br />
if (pPicture)<br />
{<br />
CComQIPtr<IPersistStream, &IID_IPersistStream> p(pPicture);<br />
if (p)<br />
{<br />
ULARGE_INTEGER l;<br />
p->GetSizeMax(&l);<br />
HGLOBAL hGlob = GlobalAlloc(GHND, l.LowPart);<br />
if (hGlob)<br />
{<br />
CComPtr<IStream> spStream;<br />
CreateStreamOnHGlobal(hGlob, TRUE, &spStream);<br />
if (spStream)<br />
{<br />
if (SUCCEEDED(p->Save(spStream, FALSE)))<br />
{<br />
LARGE_INTEGER l;<br />
l.QuadPart = 0;<br />
spStream->Seek(l, STREAM_SEEK_SET, NULL);<br />
OleLoadPicture(spStream, l.LowPart, FALSE, IID_IPictureDisp, (void**)&m_spPictures[nEntry]);<br />
}<br />
spStream.Release();<br />
}<br />
GlobalFree(hGlob);<br />
}<br />
}<br />
}<br />
m_bRequiresSave = TRUE;<br />
FireOnChanged(nEntry + 3);<br />
FireViewChange();<br />
SendOnDataChange(NULL);<br />
<br />
<br />
return S_OK;<br />
<br />
}<br />
|
|
|
|
|
First: despite the names, <pre> produces better-formatted code than <code> .
If your control is implemented as a DLL, it will be loaded into the container's process. I'm not sure that OLE Controls/ActiveX Controls work out-of-process, in any case.
COM may introduce a proxy if the thread creating the control is not in a single-threaded apartment at the time the control is created.
Your profiler output lists, in order of time spent in the function and the functions it called (children above), the functions that were called in the profiler run. The top function called (i.e., the one in which most time was spent) was WaitForSingleObject .
WaitForSingleObject , of course, is a system function. There's not a lot you can do to that, apart from ensuring that you're only holding synchronisation objects as long as you need them, and no longer.
Function names beginning with '#' are functions where the DLL exports the function by ordinal, not by name. The MFC DLLs do this to save about 1MB of space for the name table, and to improve loading speed. To find the function, ensure that you have the MFC source code installed, then look for the file mfc71d.def - typically in C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\src\Intel (IIRC). This file lists the decorated name of the function (on the left) and its ordinal (on the right, after the '@' symbol). Use the SDK tool undname to undecorate the name. If there are multiple overloads of the function, use the -f switch to find out which one.
For example, MFC 6 has the following for ordinal #1718:
?CreatePointFontIndirect@CFont@@QAEHPBUtagLOGFONTA@@PAVCDC@@@Z @ 1718 NONAME undname -f gives
C:\>undname -f ?CreatePointFontIndirect@CFont@@QAEHPBUtagLOGFONTA@@PAVCDC@@@Z
Microsoft(R) Windows NT(R) Operating System
UNDNAME Version 5.00.1768.1Copyright (C) Microsoft Corp. 1981-1998
>> ?CreatePointFontIndirect@CFont@@QAEHPBUtagLOGFONTA@@PAVCDC@@@Z == public: int
__thiscall CFont::CreatePointFontIndirect(struct tagLOGFONTA const *,class CDC
*) Working across the profiler's output, you have: the name of the function, the percentage of time spent in this function's code (not including functions it called), the percentage of time spent in this function and the functions it called, the number of times this function was called, and the average time to execute each call.
The function that spent the most time, that you wrote, is PtAllSet::baseGet. You should probably look to see whether the algorithm this function uses can be improved.
|
|
|
|
|
I know what have written.
except I think
STA is included to APARTMENT, as sub-circle.
just some STA can be as APARTMENT settled to application.
But what about mutli-threading at STA?
than,
I need explanation what problem code makes
so WaitForSingleObject() so much?
What is the DLL and exports I know.
|
|
|
|
|
I am trying to have shrared data in dll and i have got no of option using memory mapped files and #pragma data_seg(".SHARDAT")
The problem i am running into is that i have a pointer of a root of the linked list now what i want to do is allocate memory to it and i have put this in to
#pragma data_seg(".SHARDAT")
CLinkedList *pRoot;
#pragma data_seg
now i want to fill the linked list with contents based on some input and its dynamic memory allocation all right chain formed.
Any process can add into it
My question here is that i have taken a look at number of tutorials on memory mapped files and shared data seq but in all the case the data of the object was fixed
class Cobj
{
int i;
char str[255];
}
etc and sizof was used to allocate memory to it both in case of memory mapped and shared data.
i want to keep a pointer and memory could be allocated by any proces number of instance of application connecting.
Is there any method of global memory allocation visible to all processes and at the same time dynamic at runtime.
I actually want to shared data through dll any help, suggestions,links etc are more than welcomed.
|
|
|
|
|
You need to create a shared memory section, which the Win32 API refers to as a file mapping object.
See the documentation for CreateFileMapping .
You will need to allocate memory from and resize your mapping as appropriate.
Another method would be to have one process be responsible for managing the memory and the shared data, and have the others communicate with that process via Windows messages.
The implementation is left as an exercise for the reader
|
|
|
|
|
As i have mentioned that i have done study on them but they all let you have to specify memory(exact) and in which you cannot store pointers.
Pointers in one address space invalid in another.
Should i make it this way that same pointer offset stroed
i.e. 0xabcdef12 in one process then all the processes have same memory place reserved.
Ok vc++.net bible there is a mechanism which uses placement new operator by specifying a physical memory address but for that the author has already reserved memory in the shared data segment of dll using
#pragma data_seg(".SHARDAT")
static char lpszMemory[sizeof(CTest)];
CTest* g_pTest=NULL;
#pragma data_seg
g_pTest = :: new (lpszMemory) CTest;
but the same problem size specified.
As you might have seen i need it for the linked list any length, growing and growing using new from any process.
Ok let's keep the problem to windows 95.
Could it be that on windows 95 whatever memory i allocate all the process that address and access it.I need help on the mechanism should i use globalalloc or what.
Thank you in advance.
|
|
|
|
|
i dont really know what u want.. but i suppose this #pragma data_seg(".SHARDAT") is not enough
#pragma comment( linker, "/SECTION:.SHARDAR,rws" ) makes the data shareable
Don't try it, just do it!
|
|
|
|
|
I want to write a general plugin for winamp in VC++.Can some one provide me with a code to do it?Is it possible to write winamp plugins in any other language?
More over I want to use the plugin for a specific purpose.I want to check the winamp for every 100ms and add the details for the song being played at that instant in the database.Please help me in doing this job.
Karteek
|
|
|
|
|
i added a delete record function which take in a ID and search the database to delete the record with this ID but i think my code is not correct:
Assuming database already open,
void CDlgDelete::OnOK()
{
UpdateData(TRUE);
CString deleteID = m_str_deleteID;
recordset.Find(AFX_DAO_FIRST, "ID = deleteID");
recordset.Delete();
recordset.Update();
recordset.Close();
database.Close();
CDialog::OnOK();
}
can someone help mi?
|
|
|
|
|
CString deleteID;<br />
deleteID.Format("ID = %s", m_str_deleteID);<br />
recordset.Find(AFX_DAO_FIRST, deleteID);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hello everyone:
I want to invoke a function at a regular interval (for example, 1 second)
on Windows platform. But I am worried about the precise of time interval
I can get on Windows platform.
Anyone knows what is the best method of invoking a function at a regular
interval on Windows platform? Are there some sample codes?
regards,
Geo
|
|
|
|
|
Use SetTimer() function and process WM_TIMER message. But if you really need extra precission, I'm aware what this case requires external clock device.
Regards,
Alexander Fedorenko,
Author of DevPlanner - tool for effective planning in development.
|
|
|
|
|
The User timers (WM_TIMER ) are accurate to about 55ms, and are dependent on not much happening in the system, since WM_TIMER has the lowest priority (see the documentation for GetMessage[^]).
If the system is busy, these timers will end up fairly inaccurate.
For more accuracy, use a multimedia timer. See timeSetEvent[^] for more details.
|
|
|
|
|
Thanks, Mike buddy!
George
|
|
|
|
|
Thanks, sashaf buddy!
What do you mean "external clock device"?
regards,
George
|
|
|
|
|
Hello everyone:
What is the difference the following two declarations, what are their advantage and
disadvantage? Or difference usage? Can anyone show me an example?
----------
typedef enum foo_ {
CON_1,
CON_2
}foo;
----------
and
----------
enum goo_ {
CON_1,
CON_2
}
----------
Thanks in advance,
Geo
|
|
|
|
|
http://www.codeguru.com/forum/showthread.php?s=&threadid=194304
|
|
|
|
|
Thanks, Alex buddy!
It is really a nice thread.
regards,
George
|
|
|
|
|
In C, enum s, struct s and union s have their own namespaces. To use them elsewhere, you must say (for example) enum goo_ .
The use of typedef adds a new name to the global type namespace, where the name can be used without qualifiers. Therefore you can declare a variable of type enum foo_ just by using the type name foo .
C++ removes this distinction; while enum s may still be referenced by prefixing enum , this is no longer required. This may break some C code if the C code uses the same name for both an enum and a typedef . Therefore all of foo , foo_ and goo_ can be referenced directly. You can still refer to foo_ and goo_ as enum foo_ and enum goo_ respectively.
Examples:
foo bar; <font color="green"></font>
foo_ bar2; <font color="green"></font>
enum foo_ bar3; <font color="green"></font>
goo_ bar4; <font color="green"></font>
enum goo_ bar5; <font color="green"></font>
struct foo { int i; }; <font color="green"></font>
int foo_; <font color="green"></font>
|
|
|
|
|
Thanks, Mike buddy!
I do not understand the why the following two statements are OK or error, can you give me a simple explanation?
Quote:
----------
struct foo { int i; }; /* C: OK, C++: error */
int foo_; /* C: OK, C++: error (IIRC) */
----------
regards,
Geo
|
|
|
|
|
OK, let me try to explain namespaces again, a bit clearer this time hopefully!
Let's start with the global scope. In this scope, you can declare variables, functions and (through the typedef keyword) types.
In C, names that are introduced with the struct , union or enum keywords share another, separate, namespace which I'll call the structure namespace. Names can exist in both the global and the structure namespace with no problems. To access a name in the structure namespace, you must use the same keyword you used to declare it (i.e. if foo is an enumeration, you must use enum foo ).
typedef can always be used to add a type name to the global namespace, whatever namespace the original type came from.
C++ changes the rules a bit. Types declared with the struct , union , enum and class keywords are still in a structure namespace; however, you no longer need to introduce them with the keyword when they're used.
Let's reproduce the example so it compiles:
1 typedef enum foo_
2 {
3 FOO_BAR_1,
4 FOO_BAR_2
5 } foo;
6
7 enum goo_
8 {
9 GOO_BAR_1,
10 GOO_BAR_2
11 };
12
13 struct foo { int i; };
14
15 int foo_; The declaration at line 13 is NOT an error in C because the earlier foo at line 5 is a typedef name and hence is in the global namespace, while the declaration at 13 creates a foo in the structure namespace. It IS an error in C++ because it tries to introduce a new type with the same name.
However, I was wrong about line 15. It's OK in both C and C++. While you can't have a variable with the same name as a type in the global namespace, you're permitted to have one with the same name as a type in the structure namespace.
Results were compared with VC6 and with Comeau Computing's online compiler[^].
Note that I had to change the names of your enumerators (the values of the foo_ and goo_ enumerations). These are also added to the global namespace, and therefore would clash with each other if they had the same names.
Now to scopes: there is a 'global' and a 'structure' namespace within each scope that names can be declared in. A namespace using the C++ keyword is a named scope. Therefore you can refer to, for example, 'std::struct pair '.
|
|
|
|
|
Thanks, Mike buddy!
George
|
|
|
|
|
Hi there
I create a vector of size(10)
using a for loop to insert values into the vector
for(int i = 0; i < 10; ++i)<br />
v.push_back(i + 0.1);<br />
<br />
for(int i = 0; i < 10; ++i)<br />
cout << v[i] << "\n";
Only display zero's on screen, When i dont put in an initial size the vector diplays what i want.
is it possible and to use v.size() rather than 10
in the for loops, but also displays zero's and warings
at compile time.
Am i doing something wrong!
Help!
Regards bhangie
|
|
|
|
|