Tuesday, 18 October 2011

Why is my application slow?

I've used plenty of CPU / GPU profiling solutions on various platforms before, so when it finally became time to profile a win32 app I had written I looked around for a decent method.
This turned out to be surprisingly hard! Nothing decent was built into Visual Studio professional. I don't have the Team edition, so I cannot comment there, although why such a fundamental thing as a profiler is not present by default is a mystery.
Sure, I could go old skool and fill my code with clock checking around suspect functions, but surely there's a faster way.

VTune - this I just did not get on with. Pricey too. Had to system restore in the end to get my system back up.

AMD CodeAnalyst - promising, but not there yet.

Windows performance analysis tools (Xperf) - I'm happy in a command line environment, but this just got too fiddly.

Very Sleepy - Within one minute of download I had all the bottlenecks in my application in front of me.. even with call stacks. HURRAH!!

...so a mega thumbs up to http://www.codersnotes.com/sleepy
Free too!

and another.. also shows source line. A bit more techy, but still free!
http://lukestackwalker.sourceforge.net/


Monday, 21 March 2011

Windows XP - Cant open applications? Window elements missing?

I've been using XP for years, usually doing 10 things at once, and therefore having plenty of windows open. Eventually I'll open an explorer window and it will look malformed, or I'll run an application and it will start acting very strange.
The solution I've had to employ is to close down some of the lesser-needed windows and then try again, usually with success. It's as if there's a memory leak, but there's no sign of any lack of free memory.
This mystery plagued me for so long until I eventually found the cause and a fix.. An internal memory heap needed to be expanded to accommodate all these windows!

It involves a registry tweak and a reboot, but microsoft have provided a foolproof fix to run, which I used and it's finally removed the only problem I've had with XP. Wish I had found it years ago.. argh!
http://support.microsoft.com/kb/126962 (Scroll down and click on "Fix It")

Install, reboot, open all the windows you want without fear of hitting any hidden limits. (well, eventually maybe!)

Wednesday, 24 November 2010

error C2662: cannot convert 'this' pointer from 'const

error C2662: cannot convert 'this' pointer from 'const

OK I've fallen for this one too many times now! What is means is that you are calling a function on a const object, and the compiler is worried that the function will modify the object.. so assuming it doesnt then add const to the end of the declaration and all will be well in the world again.

class MyClass
{
void Func() const;
}

Monday, 13 September 2010

Getting the time into a filename using a batch file

I'm repeatedly grabbing some data from an external device, and I want it stored locally under a suitable filename which includes the time for reference.


:loop
SET now=%date:~6,4%-%date:~3,2%-%date:~0,2%-%time:~0,2%-%time:~3,2%-%time:~6,2%
grabdata.exe data%now%.bin

REM The line below forces a pause for two seconds. Very handy!
@ping 127.0.0.1 -n 2 -w 1000 > nul

goto loop


A quick work of warning - you may need to adjust the parameters of the date to match your location.
when I type at the command prompt
echo %date%
I get
13/09/2010
so be prepared to modify if you don't have DD/MM/YYYY format.




Tuesday, 31 August 2010

Project : error PRJ0003 : Error spawning 'resgen.exe'.

Project : error PRJ0003 : Error spawning 'resgen.exe'.

Kept getting this in vs2008. Searched for resgen.exe and it existed in the windows SDK directory.

So simply go to Tools/Options/ProjectsAndSolutions/VC++ Directories and append "C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin" or whatever to the Executable files list. Sorted!

Saturday, 28 August 2010

System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.

System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security.

Argh! Been trying to install a service for about 2 hours. I followed the wizard in vs2008 to create a new service, added a call to start a thread of my code, hit compile, removed unicode and set to clr, hit compile again, and woo an EXE. Opened a command prompt, typed in "myservice.exe -Install" and oh dear.. failure. Seems I had to right click some crazy stuff and "Add Installer".. Sure I didnt have to do that part last time I made a service. Odd. So did it anyway, and tried again.
Still no luck! Tried creating an ASPNET admin user on my machine.. nope..
Some progress was made when switching properties from Local Service to Local System.. but the big breakthrough came when I closed my command prompt and opened another one as administrator.
Still not convinced by all this admin crud in Win7. Not sure it's an advance on XP in that regard. Ho hum, it looks like I've got a service to play with at last :)

Monday, 23 August 2010

The application has failed to start because its side-by-side configuration is incorrect.

Argh!
I recent spent a very frustrating day trying to get a program that was built with vs2005 running on a pc without visual studio installed. Any pc with visual studio installed had no problem running the simple exe, but without, this error always appeared:
"The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail."
Straight away I meddled with "Multi-threaded / Multi-threaded DLL", but going totally static wasn't possible as some external librarys were being used that insisted on DLL action. So forget the static, and play nice.. Installed vs2005 runtime on the target machine, and vs2005 runtime SP1. Still no luck. I was compiling in XP, and vista was on the target machine. Maybe an issue there? The vista machine probably wasn't up to date with windows updates too.
Anyway, six frustrating hours later, I opened up the project in vs2008 instead, converted it, and soon managed to get it to compile. This worked!
So it looks like I'll be using vs2008 for all my pc projects now.