StorageDevice.IsConnected garbage

Nov 15, 2010 at 4:54 AM
Edited Nov 15, 2010 at 4:55 AM

I'm using the 57440 latest (as of writing this message) version of EasyStorage. This is the Windows XNA 4 version and I'm using PlayerSaveDevice to save my data, and it works just fine. However I recently noticed that it causes a LOT of garbage (my game normally has a collection every few minutes, EasyStorage caused it to happen every 5-10 seconds).

I ran a CLR Profiler on it, and discovered that it was StorageDevice.IsConnected that was causing all the garbage, and it creates all kinds of things from various functions like System.Char[], System.String, System.Object[] and Collections.ArrayList and more.

I had no problems like this with the previous XNA 3.1 versions I was using. I haven't tested the Xbox version.

Jun 2, 2011 at 8:12 AM

I'm having the same issue here. Has someone managed to address this?

Aug 14, 2011 at 8:48 PM

I'm having a similar issue, although it's mainly coming in the form of Strings and Char[], but it all stems from EasyStorage.

Worst part of this is that it's causing my GarbageCollector to run like crazy on the Xbox, (i.e. 60 times a second).  I'm currently working on it, and I'll let you guys know if I find a solution.  At the very least, maybe we can make it update less, like only when you try to save or load.

I'll investigate further and report back.

Oct 19, 2011 at 10:42 PM

Just came across this problem myself, any updates? Hasn't been any posts recently, so not holding my breath..

Oct 20, 2011 at 10:59 AM

Had a closer look, and it seems that in SaveDevice.Update() it queries StorageDevice.IsConnected every frame. This only apepars to be used to detect when to notify the player that the storage device has been removed, and then prompt or force them to select a new device. IsConnected is also queried when attempting to read/write, to verify the device is connected.

For now, I've just setup a timer so that deviceIsConnected is only updated every 5 seconds. The only side-effect of this would be a delay of upto 5 seconds before prompting the player to reconnect a storage device.

I've read on a thread in the apphub forum that instead of polling StorageDevice.IsConnected, there is an event that is triggered to notify a change to the connection status of a StorageDevice. Would it be more appropriate to hook this event and then prompt the player as per usual, rather than keep checking IsConnected?

I don't have the code infront of me, but I'll give it a try tonight.