[quote author="Gerolf" date="1301636313"]but the checks are cheap, compared to deep copying stuff.[/quote]
Of course -- my point was that you have no control upon them and you pay for them even if your container is not shared at all. The same thing, mutatis mutandis, applies for any implicitly shared class.
[quote]Having spent many years programming for hand held devices, dealing with low and no memory was always high on the list of the way we programmed. And so was important and was effectively dealt with in many/most situations. Do you really think it is acceptable for for a word processor or spreadsheet to crash due to low memory and loose sever hours of the users work? It is very difficult to add this sort of robustness to code after you have written it – it has to be done right from the start[/quote]
You're absolutely right and I wasn't disagreeing with you. My point was: when a OOM happens, there's almost nothing you can safely do except from crashing the application. Anything you do is at risk of failing again because it tries to allocate more memory.
SC_HANDLE hScManager = OpenSCManager(0, // local computer or add computer name here
0, // SERVICES_ACTIVE_DATABASE database is opened by default.
GENERIC_READ); // onyl read info
if(0 != hScManager)
SC_HANDLE hSvc = OpenService(hScManager, // service manager
ServiceName, // service name
GENERIC_READ); // onyl read info
if(0 != hSvc)
DWORD bytesNeeded = 0;
if(QueryServiceStatusEx(hSvc, // A handle to the service.
SC_STATUS_PROCESS_INFO, // info requested
(LPBYTE)&sInfo, // structure to load info to
sizeof(sInfo), // size of the buffer
if(sInfo.dwCurrentState == SERVICE_RUNNING)
traymessage("test", "start!!!", 3);
traymessage("test", "stop!!!", 3);
What's the rationale behind this? To my knowledge even in poor old C (without ++) "0" is the all-valid constant for a null pointer (regardless of the internal representation for the actual machine). So
marswith: That tool is called ar. Mac, Linux and windows use this really simplistic packaging tool to store a set of object files into a static library. Of course all OSes use slightly different formats in the ar files they call static libraries;-)
Remember to run your benchmarks on a release build.
You can also use valgrind --callgrind to get a trace of where your app spends each fraction of its time. You can view the output with kcachegrind. This will let you know where to focus your optimisation efforts.
[quote author="ryadav" date="1298140567"]
How do I determine what modules link to a binary or are loaded in a running process?
Also is there a system logger on Linux? On Window I can use of OS Event Logging and Performance monitoring counters. Is there an equivalent on Linux?
To see what dynamic libraries are needed by an app at runtime use:
You can use strace to get a trace of every syscall made by your application. Use it like:
The output will be very verbose so it is often useful to redirect it into a file that you can grep later.
Another useful tool is "lsof" which will tell you about all of the open file handles your application has.
Do not be afraid to make use of qDebug() statements. You can easily disable them in a release build by defining QT_NO_DEBUG_OUTPUT. ie just add
// Makes sure that environment works for new and delete -operators.
int *i = new int(2);
QWidget *w = new QWidget();
Sorry, this is not the place to ask for explanations on code you found somewhere on the web. How about asking the author of that code?
For general information on how to calculate an adjacency matrix, I'd like to refer you to the math section of your nearest university library, the almighty interweb or I'd like to suggest you simply use the Boost::graph library.
I moved the headers, and I found that the problem might lie in the classes. They reference some classes that also use winserialport.h and other classes. I think there might be a class that uses startpage so I changed the class name and the associated files and all is well. Now I ran accross another problem. But I will start a new post. I am not sure if it should be in QT or here in C++ I think it should go in QT as the error references a qt file.
As far as the compilation speed goes - this way you can minimize the number of includes (a small speed boost) and you can change classes(1) without having chain reactions to recompile everything that uses them (big speed boost).
You can do this with map or multimap containers, or you can creat your own container if you know somethink about OOP and templates :) it is fun and when you end container you will be pround :) but faster way is use one of containers from STL
[quote author="Tobias Hunger" date="1294679366"]Wolf P.: You only use two compilers? You are lucky then![/quote] How many compilers do you use?
BTW: this sounds like a suggestion for one of our next polls ;)
Sorry, if I wasn't clear. I made two suggestions to solve your problem and the longer i think about the first one the less I like my own solution. Because it would work in another way than the standard library and thus may confuse readers of your code.
I as an user of your binary heap would expect that the implementations calls operator<(T, T) for all possible T in the same way.