Merge "Deprecate the allocation limit interfaces." into honeycomb

This commit is contained in:
Carl Shapiro
2011-01-12 17:02:18 -08:00
committed by Android (Google) Code Review
2 changed files with 15 additions and 38 deletions

View File

@@ -140392,7 +140392,7 @@
synchronized="false" synchronized="false"
static="true" static="true"
final="false" final="false"
deprecated="not deprecated" deprecated="deprecated"
visibility="public" visibility="public"
> >
<parameter name="limit" type="int"> <parameter name="limit" type="int">
@@ -140405,7 +140405,7 @@
synchronized="false" synchronized="false"
static="true" static="true"
final="false" final="false"
deprecated="not deprecated" deprecated="deprecated"
visibility="public" visibility="public"
> >
<parameter name="limit" type="int"> <parameter name="limit" type="int">
@@ -260056,7 +260056,7 @@
deprecated="not deprecated" deprecated="not deprecated"
visibility="public" visibility="public"
> >
<parameter name="arg0" type="T"> <parameter name="t" type="T">
</parameter> </parameter>
</method> </method>
</interface> </interface>

View File

@@ -774,50 +774,27 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo
public static native void getMemoryInfo(int pid, MemoryInfo memoryInfo); public static native void getMemoryInfo(int pid, MemoryInfo memoryInfo);
/** /**
* Establish an object allocation limit in the current thread. Useful * Establish an object allocation limit in the current thread.
* for catching regressions in code that is expected to operate * This feature was never enabled in release builds. Now that
* without causing any allocations. * allocation limits have been removed this method has no effect.
* *
* <p>Pass in the maximum number of allowed allocations. Use -1 to disable * @deprecated This method is now obsolete.
* the limit. Returns the previous limit.</p>
*
* <p>The preferred way to use this is:
* <pre>
* int prevLimit = -1;
* try {
* prevLimit = Debug.setAllocationLimit(0);
* ... do stuff that's not expected to allocate memory ...
* } finally {
* Debug.setAllocationLimit(prevLimit);
* }
* </pre>
* This allows limits to be nested. The try/finally ensures that the
* limit is reset if something fails.</p>
*
* <p>Exceeding the limit causes a dalvik.system.AllocationLimitError to
* be thrown from a memory allocation call. The limit is reset to -1
* when this happens.</p>
*
* <p>The feature may be disabled in the VM configuration. If so, this
* call has no effect, and always returns -1.</p>
*/ */
@Deprecated
public static int setAllocationLimit(int limit) { public static int setAllocationLimit(int limit) {
return VMDebug.setAllocationLimit(limit); return -1;
} }
/** /**
* Establish a global object allocation limit. This is similar to * Establish a global object allocation limit. This feature was
* {@link #setAllocationLimit(int)} but applies to all threads in * never enabled in release builds. Now that allocation limits
* the VM. It will coexist peacefully with per-thread limits. * have been removed this method has no effect.
* *
* [ The value of "limit" is currently restricted to 0 (no allocations * @deprecated This method is now obsolete.
* allowed) or -1 (no global limit). This may be changed in a future
* release. ]
*/ */
@Deprecated
public static int setGlobalAllocationLimit(int limit) { public static int setGlobalAllocationLimit(int limit) {
if (limit != 0 && limit != -1) return -1;
throw new IllegalArgumentException("limit must be 0 or -1");
return VMDebug.setGlobalAllocationLimit(limit);
} }
/** /**