本文整理汇总了C#中Class.release方法的典型用法代码示例。如果您正苦于以下问题:C# Class.release方法的具体用法?C# Class.release怎么用?C# Class.release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Class
的用法示例。
在下文中一共展示了Class.release方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: App
public App(string nibName)
{
NSObject app = (NSObject) new Class("NSApplication").Call("sharedApplication");
// Load our nib. This will instantiate all of the native objects and wire them together.
// The C# SimpleLayoutView will be created the first time Objective-C calls one of the
// methods SimpleLayoutView added or overrode.
NSObject dict = new Class("NSMutableDictionary").Call("alloc").Call("init").To<NSObject>();
NSObject key = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto("NSOwner")).To<NSObject>();
dict.Call("setObject:forKey:", app, key);
NSObject bundle = new Class("NSBundle").Call("mainBundle").To<NSObject>();
NSObject nib = new Class("NSString").Call("stringWithUTF8String:", Marshal.StringToHGlobalAuto(nibName)).To<NSObject>();
sbyte loaded = (sbyte) bundle.Call("loadNibFile:externalNameTable:withZone:", nib, dict, null);
if (loaded != 1)
throw new InvalidOperationException("Couldn't load the nib file");
// We need an NSAutoreleasePool to do Native.Call, but we don't want to have one
// hanging around while we're in the main event loop because that may hide bugs.
// So, we'll instantiate a Native instance here and call Invoke later which can
// be done without an NSAutoreleasePool.
m_run = new Native(app, new Selector("run"));
dict.release();
}
示例2: Released
public void Released()
{
NSObject pool = new NSObject(NSObject.AllocAndInitInstance("NSAutoreleasePool"));
long bytes = DoGetMemory();
for (int j = 1; j < 100; ++j)
{
for (int i = 0; i < NumIterations/100; ++i)
{
Class klass = new Class("NSNumber");
klass.release();
}
GC.Collect();
}
pool.release();
GC.Collect();
GC.WaitForPendingFinalizers();
long delta = DoGetMemory() - bytes;
if (delta/NumIterations > 4)
Assert.Fail("Released used {0}K of memory ({1} bytes per iteration)!", delta/1024, delta/NumIterations);
}