views:

29

answers:

2

I developed a C# application that makes use of Congex vision library (VPro). My application is developed with Visual Studio 2008 Pro on a 32bit Windows PC with 3GB of RAM.

During the startup of application I see that a large amount of memory is allocated. So far so good, but when I add many and many vision elaboration the memory allocation increases and a part of application (only Cognex OCX) stops working well. The rest of application stills to work (working threads, com on socket....)

I did whatever I could to save memory, but when the memory allocated is about 700MB I begin to have the problems. A note on the documentation of Cognex library tells that /LARGEADDRESSWARE is not supported. Anyway I'm thinking to try the migration of my app on win64 but what do I have to do?

  • Can I simply use a processor with 64bit and windows 64bit without recompiling my application that would remain a 32bit application to take advantage of 64bit ? Or I should recompile my application ?
  • If I don't need to recompile my application, can I link it with 64bit Congnex library?
  • If I have to recompile my application, is it possible to cross compile the application so that my develop suite is on a 32bit PC?

Every help will be very appreciated!!

Thank in advance

+2  A: 

You can run 32 bit apps on a 64-bit OS, but they run in "WoW" (windows on windows). That is, they still run as a 32 bit app, with all the restrictions a 32-bit app has. To run as a native 64 bit app, they have to be proper 64 bit applications.

Managed (C#) code is not 32/64 platform-specific - it will be JIT compiled into the correct sort of code to run natively on the host PC. However, any unmanaged code (C++, most third party dlls) will have been pre-compiled as 32-bit or 64-bit, so you have to use the correct version of the dll for your host PC.

If you try to run your program on 64 but use a 32-bit dll, when you try to call the dll your program will simply crash with a "bad image format" error.

So... to make your program truly 64 bit, you will need to build a version that links to the 64-bit Congnex library.

You can target any type of processor from Visual Studio, so you don't need to have a 64 bit PC to develop a 64 bit app (although you will beed a 64-bit pc to test it on!)

Jason Williams
Thanks for your clear answer. So the most difficult step now is to determine wich architecture I exactly have to recompile the part in C++ of my appliance.I think I have to set Properties->Linker->Advaced->Targer Machine to one of that architecture. I have an Intel Core 2 Duo E6400, do you know what is the best choice? Prehaps "/MACHINEx64?
picciopiccio
Yes, that's right. If you are targeting 32-bit, use /MACHINE:x86. For 64-bit Intel/AMD, use /MACHINE:x64. In the button bar there is a drop-down list (usually with Any CPU or Win32 in it). Drop this down and choose the Configuration Manager, and you can add a new configuration for x64 (copy it from Debug or Release as approriate and set the appropriate linker options for 64-bit) - then you can just switch between 32/64 bit builds by dropping down that combo-box just as you switch between debug/release.
Jason Williams
+2  A: 

Project + Properties, Build tab, Platform Target. That should be set to Any CPU, the default. Which will automatically make your code run 64-bit when you run it on a 64-bit version of Windows. The JIT compiler takes care of it.

You will have to install the 64-bit version of the .ocx on the machine to make this work.

Hans Passant