5

I have a resource (.resx) file, and it have currently 58 string properties. This amount of string properties can grow..

My doubt is, are those strings kept in memory? If i have 200, will all be kept in memory? Or the the strings are kept in file and the ResourceManager access the file? Or anything else? How this work?

Vinicius Ottoni
  • 4,631
  • 9
  • 42
  • 64

1 Answers1

4

Generally the .resx file is compiled into a .resources with resgen.exe file and stored as an assembly resource within the assembly itself. If you look at the properties of the ResX file in your Visual Studio project, you'll see that the Build Action is Embedded Resource, which is what causes it to become embedded into the assembly. So any time the assembly is loaded you will load the resource file as well. There might be another way to use resource files that does not keep them in memory but this is the normal way they are used.

luksan
  • 7,661
  • 3
  • 36
  • 38
  • That (the strings in memory) could generate a memory overhead? There is a amount of string properties that i have to worry (about memory overhead)? – Vinicius Ottoni Feb 29 '12 at 18:08
  • 200 strings does not sound like a lot to me at all. However, if you're worried about memory consumption, check the Memory (Private Working Set) column of Windows Task Manager for the process when it is running. If the memory consumption is unacceptable, you will need to look into another mechanism of loading the strings, one that doesn't use embedded resource strings. – luksan Feb 29 '12 at 18:57
  • Also keep in mind that modern operating systems have virtual memory, so they can swap memory pages out to the disk when memory is low. – luksan Feb 29 '12 at 18:59