0

In my Windows Phone 8 application I have a class that stores in a static variable temporarily an object to be used between pages in navigation. The problem is when this object is too big, like for example a big array of bytes (about 1,000,000 bytes), this variable is simply set to null when navigation occurs. Why does this happen? Is there a way to prevent this behavior?

wm1sr
  • 1,905
  • 1
  • 16
  • 20
  • What have you done to investigate the issue so far? Have you run the program in a debugger? How do you know the object "is too big"? Is there any symptom of being "too big" _other_ than the null value in the field? Is an exception thrown? You will have a much better chance at getting a useful answer if you write a good question. – Peter Duniho Oct 15 '14 at 18:33
  • There isn't much to say. In the byte array case, for example: I have an object that has a byte array. The field that holds this byte array is simply set to null whenever navigation occurs. The parent object remains intact though. This behavior used to happen just in this particular case, but today it happened again in a different scenario: An object, somewhat big, because it references some other objects and so on. Some of these objects has big collections of data (about 200 items). In this case, the root object is set to null, not one of its fields. – wm1sr Oct 15 '14 at 20:57
  • I agree that I should do some testing before asking to give you something more consistent, but I really don't where to begin. I would be grateful if you could give me some ideas on how to inspect this a bit more. – wm1sr Oct 15 '14 at 21:03
  • You could start by addressing the questions I posed in my first comment. As far as debugging the issue goes, you should run the code in a debugger and see what is setting the field to null. Unfortunately, AFAIK Visual Studio hasn't supported hardware watchpoints for a long time, so setting a breakpoint on a field changing will run very slow. But it's an option. Alternatively, search for all assignments to the field and set breakpoints on each assignment. After all, it's not likely that .NET is setting it back to null behind your back; most likely you have some code yourself that is doing it. – Peter Duniho Oct 15 '14 at 21:15

0 Answers0