Question

I'm building a WP8 that has a background task running (ScheduledAgent). When the task runs, it loads from isolated storage an object graph that was serialized using protobuf. The class model consists of about 10 classes, with a head object, User, that has lists of other class instances. Not a trivial model, but not excessively complicated.

My issue is, that by the time the graph is restored, most of my allotted memory is consumed (roughly 1 MB limit for the scheduled task). I've narrowed down the main culprit as being protobuf itself. I assume the runtime meta information about the class model is consuming most memory, but calling FlushPool doesn't seem to help at all.

Restoring empty object graphs consumes about the same about of memory as a fully loaded object. I'm looking for any way possible clear all memory references held internally by protobuf, and then call GC.Collect, hoping to recover enough to do the actual work. Is there something different then FlushPool()?

Thanks

Was it helpful?

Solution

Any additional overhead could be coming from the reflection and meta-programming aspects of the "Full" build. The good news is that if so: you can remove all of that by using the precompiler to move all the meta-programming to a build step. To make sure that you aren't including any of the meta-programming code you can use the "CoreOnly" build with the generated serialization assembly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top