No GC messages in debug

Hi,

I’m not getting any garbage collector messages in debug, any ideas why? I’ve got

Debug.EnableGCMessages(true)

in my main method but still nothing.

Thanks

@ wolfbuddy - you are using memory so efficiently that GC is not occurring?

I doubt it!! In all honesty, I’m very new to programming so it’s unlikely. I mean I’ve been writing all sorts of wrongness and I’m still yet to see a GC message.

:smiley:

Is it really as simple as that? No other way that stopping GC messages?

Try this. Just in case you are accidentally writing totally awesome GC free code :wink:

            
for (var i = 0; i < 100000; i++)
{
    var s = "i = " + i;
    Debug.Print(s);
}

[quote]GC: 1msec 271944 bytes used, 3922140 bytes available

Type 0F (STRING ): 24 bytes

Type 15 (FREEBLOCK ): 3922140 bytes

Type 17 (ASSEMBLY ): 5760 bytes

Type 1E (BINARY_BLOB_HEAD ): 265656 bytes

Type 28 (MEMORY_STREAM_HEAD ): 36 bytes

Type 29 (MEMORY_STREAM_DATA ): 396 bytes

Type 34 (APPDOMAIN_HEAD ): 72 bytes

GC: performing heap compaction…[/quote]

That’s what I got with your for loop when debugging in the emulator, but I don’t get anything when debugging to the Cerbuino with the same for loop.

So no one knows why I’m not getting GC messages when debugging to the device, but I am getting them with the emulator? Surely I’m doing something wrong somewhere! :smiley:

Enable them using debug.enableGC…

@ wolfbuddy - You running a release build instead of a debug build?

Pretty sure it’s a debug release (F5 in VSE), I’m getting all the debug messages I set myself and I don’t thinkI’m doing anything differently to when I tried it with the emulator. How odd.

It’s not the end of the world but I wanted to use it to learn how to make my programs more efficient with memory usage.

if you want to learn, then an approach would be to use debug.gc(true) and track memory consumption over time

@ Brett - Does that turn the GC off? GC(true), not GC(false)?

Sorry, debug.GC(false). It returns the available memory.

			Debug.Print("Free mem : " + Debug.GC(false).ToString());

using TRUE forces compaction to run, which also isn’t a bad thing to do.

I’ve been using that to track memory usage but the problem is, without knowing how much work the GC is having to do I can’t be sure how optimised the code is. Hence why I’m keen to work out why I’m not getting GC debug messages.