0

I have inherited a C# application that imports very large data sets. We are getting some out of memory issues and I think the problem is that the program is running as 32bit vs 64bit. The application is on a 64bit server and setup as a windows scheduled task.

I found that the test and production release have the 32bit preferred checked. This solution has about 7 projects. I was going to try to uncheck the 32bit preferred checkbox, but will I need to do these to each of the other projects that this might be using a reference?

frmrock164
  • 47
  • 11
  • 4
    What is your question? – Igor Dec 01 '21 at 21:24
  • By all means, if you're running out of memory, try running as 64-bit. Note though that you'll need more memory overall since pointers are now twice as large. The exact amount of additional memory depends on the nature of your application, but 20% has been my experience. If you have data structures with lots of pointers, it could be more. – Eric J. Dec 01 '21 at 21:26
  • Rather than wonder: IMO, just change it to be explicitly x64 rather than Any. If any of the libraries are incompatible: it'll tell you right away when you try to build. Also: if the problem is large single managed arrays: this may not help by itself - even with very-large-object support enabled, there are still some limits on vector sizes. This is particularly relevant to `byte[]`, which is relevant to what @Dai says below. – Marc Gravell Dec 01 '21 at 21:26
  • It sounds like you're reading an entire file into-memory. You _probably_ don't need to do that; why can't you read the file in buffer-sized chunks? – Dai Dec 01 '21 at 21:26
  • Doe all the projects in the solution need to have this unchecked as well? I think the server memory is at 16gb. – frmrock164 Dec 01 '21 at 21:27
  • @MarcGravell "If any of the libraries are incompatible: it'll tell you right away when you try to build" - since when `csc` done that? Otherwise we'd never get 64 vs 32-bit errors at assembly load-time. – Dai Dec 01 '21 at 21:27
  • @Dai um... I had that literally this week - complaining of an architecture mismatch between libraries, that I resolved by switching from Any to x64. I'm not saying it is foolproof, but: it does try. – Marc Gravell Dec 01 '21 at 21:29
  • The executable project's settings regulate the bittedness of the process (see linked question). – Eric J. Dec 01 '21 at 21:30
  • Re "all projects": just the executable process should be fine. That is what has the PE header (on windows, at least), which is what determines how it gets launched by the OS – Marc Gravell Dec 01 '21 at 21:31
  • I figured out why nothing was working. The TFS CI build process was had a setting for 32bit. That overwrote whatever I did in the visual studio solution. After changing the TFS Build process, It runs as 64bit. – frmrock164 May 05 '22 at 12:30

0 Answers0