|
I dont think there will be any performance issue.
|
|
|
|
|
PSEUDOCODE
int *varArray[1000000];
StartNewTime = getSystemTimer();
for (i=0; i<1000000; i++)
varArray[i] = new int;
StartDelTime = getSystemTimer();
for (i=0; i<1000000; i++)
delete varArray[i];
endTime = getSystemTimer();
elapsedNewTime = StartDelTime - StartNewTime;
elapsedDelTime = endTime - StartDelTime;
timePerNew = (float) elapsedNewTime / 1000000.0;
timePerDel = (float) elapsedDelTime / 1000000.0;
Of course, if they were C++ objects that were calling constuctors & destructors, then the answer would be different, and you would need to have an array of 1000000 (or whatever other arbitrary number suits you) pointers to objects of the type to be investigated.
Just remember - if 1 event is too quick to time effectively, then just time a whole heap of them at once.
|
|
|
|
|
Anytime you employ the use of Windows' memory manager, there will be some overhead involved. It may be negligible, but there will be some.
Is it really part of your design to allocate and release memory every second?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
ginjikun wrote: I would like to ask regarding the possible overhead/performance issue for an application (DLL) to create an object (call NEW) and destroy the object (DELETE) every 1 second?
could it don't by allocating static memory, instead of using dynamic memory. yes there could be dynamic issue, as memory allocation itself is tedious task.
how big is data??, could you code like this :-
if( MEMORY_REQUIRED > STATIC_MEMORY_ALLOCATED)
allocate DYNAMIC_MEMORY
else
use STATIC_MEMORY
now you have choose STATIC_MEMORY_ALLOCATED limits according to you.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/xml>
|
|
|
|
|
Every 1 second is not very often relative to how many operations
can be done in one second by a modern PC. I can allocate/free hundreds of video
frame buffers a second using barely any CPU.
If your allocations are too slow (for reasons others have mentioned) then you can
implement some kind of pre-allocated memory scheme.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I try to print a window, using this article:
http://support.microsoft.com/kb/186736
It works, but I want to user default printer with landscape. So I try to modify the GetPrinterDC(), like this:
HDC CLogACTsPrintHelper::GetPrinterDC(void)
{
CWaitCursor wait;
PRINTDLG pdlg;
memset( &pdlg, 0, sizeof(PRINTDLG));
pdlg.lStructSize = sizeof(PRINTDLG);
pdlg.Flags = PD_RETURNDEFAULT | PD_RETURNDC;
AfxGetApp()->GetPrinterDeviceDefaults(&pdlg);
DEVMODE* lpDevMode = (DEVMODE*)::GlobalLock(pdlg.hDevMode);
lpDevMode->dmOrientation = (short)DMORIENT_LANDSCAPE;
::ResetDC(pdlg.hDC,lpDevMode);
::GlobalUnlock(pdlg.hDevMode);
PrintDlg( &pdlg );
return pdlg.hDC;
}
But I don't know why it return NULL???
If I comment all source code in set landscape block, it works. Or if I do not use default printer and set landscape, it work
pdlg.Flags = PD_RETURNDC;
...
Can anyone explain me what's wrong here?
Thank you in advance,
|
|
|
|
|
|
Well, I don't know if you are using MFC, but I made it like that:
BOOL CMyFormView::OnPreparePrinting(CPrintInfo* pInfo)
{
delete pInfo->m_pPD ;
pInfo->m_pPD = new CDlgPrinting(FALSE, PD_ALLPAGES | PD_USEDEVMODECOPIES | PD_NOPAGENUMS
| PD_HIDEPRINTTOFILE | PD_NOSELECTION, this) ;
pInfo->m_pPD->m_pd.hInstance = AfxGetInstanceHandle();
pInfo->m_pPD->m_pd.lpPrintTemplateName = MAKEINTRESOURCE(IDD_PRINT_PRDLG);
pInfo->m_pPD->m_pd.Flags |= PD_ENABLEPRINTTEMPLATE;
pInfo->m_pPD->m_pd.nMinPage = 1;
.
.
if (pInfo->m_bPreview)
return DoPreparePrinting(pInfo);
int nAnswer = pInfo->m_pPD->DoModal ();
if (nAnswer == IDCANCEL)
return FALSE;
pInfo->m_pPD->m_pd.hDC = pInfo->m_pPD->CreatePrinterDC ();
return TRUE;
}
void CMyFormView::OnPrepareDC(CDC* pDC, CPrintInfo* pInfo)
{
if (pDC->IsPrinting ())
{ DEVMODE* devMode = pInfo->m_pPD->GetDevMode ();
devMode->dmOrientation = DMORIENT_LANDSCAPE;
devMode->dmFields |= DM_ORIENTATION;
pDC->ResetDC (devMode);
}
CFormView::OnPrepareDC(pDC, pInfo);
}
void CMyFormView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
pDC->SetMapMode (MM_LOMETRIC);
double dLeftOffset = 200 - (pDC->GetDeviceCaps (PHYSICALOFFSETX) * 254.0) / pDC->GetDeviceCaps (LOGPIXELSX);
double dTopOffset = 200 - (pDC->GetDeviceCaps (PHYSICALOFFSETY) * 254.0) / pDC->GetDeviceCaps (LOGPIXELSY);
double dRightMargin = 2770 - (pDC->GetDeviceCaps (PHYSICALOFFSETX) * 254.0) / pDC->GetDeviceCaps (LOGPIXELSX);
double dBottomMargin = 1950 - (pDC->GetDeviceCaps (PHYSICALOFFSETY) * 254.0) / pDC->GetDeviceCaps (LOGPIXELSY);
pInfo->m_rectDraw.left += (int) dLeftOffset;
pInfo->m_rectDraw.top += (int) dTopOffset;
pInfo->m_rectDraw.right = (int) dRightMargin;
pInfo->m_rectDraw.bottom = (int) dBottomMargin;
..........
.......
,....
I don't know if it is totally correct and I guess it can be optimized, but it works. I hope it helps you
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Thank you, Nelek.
I will try it now!
|
|
|
|
|
i am stuck like chuck..... i can change from low to normal and high but how do i get priority belownormal and abovenormal?
|
|
|
|
|
locoone wrote: i can change from low to normal and high
How are you doing that, chuck?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
SetPriorityClass(hHandle, HIGH_PRIORITY_CLASS); //high
SetPriorityClass(hHandle, NORMAL_PRIORITY_CLASS); //normal
SetPriorityClass(hHandle, IDLE_PRIORITY_CLASS); //low
its the belownormal and abovenormal i cant figure out
|
|
|
|
|
ABOVE_NORMAL_PRIORITY_CLASS 0x00008000
BELOW_NORMAL_PRIORITY_CLASS 0x00004000
HIGH_PRIORITY_CLASS 0x00000080
IDLE_PRIORITY_CLASS 0x00000040
NORMAL_PRIORITY_CLASS 0x00000020
REALTIME_PRIORITY_CLASS 0x00000100
There're some values for priority like above, you can try it!
|
|
|
|
|
that worked thanks
|
|
|
|
|
Hello,
i am wondering if vc++ also understands jpeg resources or only bitmaps ? It would be very nice if i can use jpegs for design elements.
Or another question: how can i build something like this:
http://cdn.last.fm/depth/screenshots/de/software_win.jpg[^]
(the left bar with the small image and the menue and the light blue bar in the mid (look at "Saalschutz")
Thanks for help.
|
|
|
|
|
gabbana wrote: i am wondering if vc++ also understands jpeg resources
GDI's LoadImage() function and GDI+'s Bitmap::FromResource() method both
load embedded JPEG BITMAP resources no problem. GIF too.
On VS2008:
(optional) copy JPEG and/or GIF file to the project's "res" folder
Right-click the project's resource (.rc) file in VS resource view
Choose "Add Resource"
Click "Import..."
Find the JPEG and/or GIF files, select them, and click "Open"
Save the project and reopen the project's .rc file in the text editor
Find the images you've embedded and change the types from "GIF"/"JPG" to "BITMAP"
The line(s) should look something like:
IDB_JPEG1 BITMAP "res\\some.JPG"
IDB_GIF1 BITMAP "res\\some.GIF"
Now you can use the above mentioned methods to work with the embedded bitmaps,
just like a bmp.
An alternative method using IStream/IPicture:
Load JPEG and (transparant) GIF picture files from a resource in 3 lines code[^]
Loading JPEG and GIF pictures[^]
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
On the design of the window you can make use of Splitters. About the Saalschutz and the blue background I guess it is a kind of progress bar. You may find a lot of info here in the CP. Take a look into that concepts if they help you.
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
okay, thanks.
do you know a good tutorial for creating a complete own gui with win32 ? So i mean owner drawn windows with my own close buttons and so on ?
i tried searching "skins" on cp but i only find apis which are easy to use but complicated to understand in the technic.
|
|
|
|
|
I am not sure what you are asking for, but actually the VC has lot of functionality and there are a lot of owner draw controls in the CP, the thing is you have to limit the search to what you need API, MFC and so on.
If you want to create your own GUI, I recommend you to make different test projects, trying one different thing in each one, and when you get what you want in every of them, then put all together.
When you have more questions just ask, there will be many people glad to help you if the question wakes up their curiosity or the question is well formulated.
Sorry, but about the manual... there are so many factors involve that I can not give you a concrete answer
Regards.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
Rating helpfull answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
Hi
I'm trying out the new features of the new VS2008 MFC Feature Pack (TR1). Managed to make a really nice looking application using 4 or 5 different CDockablePane s. All my views are now in their own pane, and the docking works really well.
Trouble is, there's a redundant CView lingering about which I a) don't have any use for, and b) don't know how to get rid of.
I tried various ways of resizing the top-level CPaneContainer using the SetPaneSize sample provided with the feature pack, which I implemented in CMainFrame::OnSize. This does work but it kinda breaks the dockable pane functionality - i.e. you can dock panes to the almost-visible CView and the whole thing screws up.
Is there an easy way to get the benefits of CFrameWnd, and get rid of CView altogether? Whilst keeping the CDockablePane functionality.
----
Edit:
Or alternatively is there a way to prevent panes from being docked onto the CView?
----
Thanks
[d3m0n]
P.S. MSDN's Feature Pack documentation is abysmal . You get more sense from stepping into the code and having a look around to see what you can call.
Cheers
[d3m0n]
Email (replace "***" with "key")
modified on Monday, July 14, 2008 4:50 PM
|
|
|
|
|
I there
This is a bit strange... I had a project (VS 2005 Pro) with all the code written in the header (.h) files. This is an OO project, so I had the class definitions and method implementations on the same file. Then, I separated the files, definition in headers, implementation in code files. But now I get 7 unresolved external symbols and the project won't compile. The strange thing is that before the separation all was normal.
What do you guys think it can be?
Best regards
Fratelli
|
|
|
|
|
AndreFratelli wrote: What do you guys think it can be?
Nothing special, just plain old coding errors. Not sure what you are asking, I mean you did not post any error messages with the related code so I don't know what you think we can do it about it short of re-writing all the C++ documentation that already exists which wouldn't make any sense since you have already proven you don't read it.
led mike
|
|
|
|
|
led mike wrote: I don't know what you think we can do it about it short of re-writing all the C++ documentation that already exists which wouldn't make any sense since you have already proven you don't read it.
You don't even have a reason to think that. I get unresolved external symbols only after separating the code into files... Wouldn't it be reasonable it would work just as well? Before, I had this:
// file whatever.h
#ifndef __WHATEVER_H
#define __WHATEVER_H
class Whatever
{
void method();
};
void Whatever::method()
{
}
#endif
Now I have this:
// file whatever.h
#ifndef __WHATEVER_H
#define __WHATEVER_H
class Whatever
{
void method();
};
#endif
// file whatever.cpp
#include "whatever.h"
void Whatever::method()
{
}
And I get these:
caminho.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Capacidade::reserva(class Fluxo)" (?reserva@Capacidade@@QAE_NVFluxo@@@Z) referenced in function "public: bool __thiscall Caminho::ligar(void)" (?ligar@Caminho@@QAE_NXZ)
caminho.obj : error LNK2019: unresolved external symbol "public: bool __thiscall Capacidade::liberta(class Fluxo)" (?liberta@Capacidade@@QAE_NVFluxo@@@Z) referenced in function "public: void __thiscall Caminho::desligar(void)" (?desligar@Caminho@@QAEXXZ)
caminho.obj : error LNK2019: unresolved external symbol "public: unsigned int __thiscall Capacidade::suporta(class Fluxo)const " (?suporta@Capacidade@@QBEIVFluxo@@@Z) referenced in function "public: bool __thiscall Caminho::ping(void)const " (?ping@Caminho@@QBE_NXZ)
grafo.obj : error LNK2019: unresolved external symbol "public: unsigned int const __thiscall No::id(void)const " (?id@No@@QBE?BIXZ) referenced in function "public: bool __thiscall Grafo::ligados(unsigned int,unsigned int)const " (?ligados@Grafo@@QBE_NII@Z)
grafo.obj : error LNK2019: unresolved external symbol "public: class No * __thiscall Ligacao::destino(void)const " (?destino@Ligacao@@QBEPAVNo@@XZ) referenced in function "public: bool __thiscall Grafo::ligados(unsigned int,unsigned int)const " (?ligados@Grafo@@QBE_NII@Z)
grafo.obj : error LNK2019: unresolved external symbol "public: unsigned int __thiscall Capacidade::custo(class Fluxo)const " (?custo@Capacidade@@QBEIVFluxo@@@Z) referenced in function "public: class Caminho __thiscall Grafo::dijkstra(unsigned int,unsigned int,class Fluxo)const " (?dijkstra@Grafo@@QBE?AVCaminho@@IIVFluxo@@@Z)
grafo.obj : error LNK2019: unresolved external symbol "public: class Capacidade * __thiscall Ligacao::capacidade(void)const " (?capacidade@Ligacao@@QBEPAVCapacidade@@XZ) referenced in function "public: class Caminho __thiscall Grafo::dijkstra(unsigned int,unsigned int,class Fluxo)const " (?dijkstra@Grafo@@QBE?AVCaminho@@IIVFluxo@@@Z)
E:\Projects\netsim\Debug\netsim.exe : fatal error LNK1120: 7 unresolved externals
I didn't include the error messages because I didn't think they would help. What I was looking for (and still am) were the kind of coding errors that would cause this, cause I really can't find what's wrong here.
I bet it will be one of those things that, when you find out what it is, you just fill like smashing the computer
regards
Fratelli
|
|
|
|
|
AndreFratelli wrote: I there
I'm sure you are.
As for your coding problems it would be helpful if you included the error messages.
Steve
|
|
|
|
|
Stephen Hewitt wrote: As for your coding problems it would be helpful if you included the error messages.
Done that =)
I already figured out what it is. I started searching what did the unresolved names add in common and notice they were all marked as inline! Removed the "inline" keyword every in the project.. and it works! Can anybody explain this? How can I solve it?
regards
Fratelli
|
|
|
|