Is this a bug in MonoTouch GC?

This is an unfortunate side-effect of MonoTouch (who is garbage collected) having to live in a reference counted world (ObjectiveC). There are a few pieces of information required to be able to understand what’s going on: For every managed object (derived from NSObject), there is a corresponding native object. For custom managed classes (derived from … Read more

What is the Metadata GC Threshold and how do I tune it?

The log message tells that GC was caused by Metaspace allocation failure. Metaspaces hold class metadata. They have appeared in Java 8 to replace PermGen. Here are some options to tune Metaspaces. You may want to set one or several of the following options: -XX:MetaspaceSize=100M Sets the size of the allocated class metadata space that will … Read more

When would the garbage collector erase an instance of an object that uses Singleton pattern?

There’s a static reference to a singleton, so it won’t be eligible for garbage collection until the classloader is eligible for garbage collection. You can’t force any object to be garbage collected; you can request that the garbage collector runs with System.gc() but it’s only a request. If you really want to make a “singleton” … Read more

Memory Allocation/Deallocation Bottleneck?

It’s significant, especially as fragmentation grows and the allocator has to hunt harder across larger heaps for the contiguous regions you request. Most performance-sensitive applications typically write their own fixed-size block allocators (eg, they ask the OS for memory 16MB at a time and then parcel it out in fixed blocks of 4kb, 16kb, etc) … Read more

How to force deletion of a python object?

The way to close resources are context managers, aka the with statement: class Foo(object): def __init__(self): = None def __enter__(self): if != ‘open’: print ‘opening the bar’”open” return self # this is bound to the `as` part def close(self): if != ‘closed’: print ‘closing the bar’”close” def __exit__(self, *err): self.close() … Read more