From 1107383e029e30bb18c77ca887db2af067a79154 Mon Sep 17 00:00:00 2001 From: Carl Shapiro Date: Wed, 12 Jan 2011 16:28:57 -0800 Subject: [PATCH] Deprecate the allocation limit interfaces. Allocation limits relied on conditionally compiled code in the virtual machine that was disabled in released versions of Android. As such, these setter methods were glorified no-ops. Now that the feature has been removed from the allocator this interface is thoroughly obsolete. Change-Id: Id7f9de37ecfece4b909e35f110e118e131457133 --- api/current.xml | 6 ++--- core/java/android/os/Debug.java | 47 +++++++++------------------------ 2 files changed, 15 insertions(+), 38 deletions(-) diff --git a/api/current.xml b/api/current.xml index 6053e1b3ddd0e..90351158f5d6e 100644 --- a/api/current.xml +++ b/api/current.xml @@ -140392,7 +140392,7 @@ synchronized="false" static="true" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > @@ -140405,7 +140405,7 @@ synchronized="false" static="true" final="false" - deprecated="not deprecated" + deprecated="deprecated" visibility="public" > @@ -260056,7 +260056,7 @@ deprecated="not deprecated" visibility="public" > - + diff --git a/core/java/android/os/Debug.java b/core/java/android/os/Debug.java index 40d9cffcb5c5f..d2b13151012a4 100644 --- a/core/java/android/os/Debug.java +++ b/core/java/android/os/Debug.java @@ -774,50 +774,27 @@ href="{@docRoot}guide/developing/tools/traceview.html">Traceview: A Graphical Lo public static native void getMemoryInfo(int pid, MemoryInfo memoryInfo); /** - * Establish an object allocation limit in the current thread. Useful - * for catching regressions in code that is expected to operate - * without causing any allocations. + * Establish an object allocation limit in the current thread. + * This feature was never enabled in release builds. Now that + * allocation limits have been removed this method has no effect. * - *

Pass in the maximum number of allowed allocations. Use -1 to disable - * the limit. Returns the previous limit.

- * - *

The preferred way to use this is: - *

-     *  int prevLimit = -1;
-     *  try {
-     *      prevLimit = Debug.setAllocationLimit(0);
-     *      ... do stuff that's not expected to allocate memory ...
-     *  } finally {
-     *      Debug.setAllocationLimit(prevLimit);
-     *  }
-     * 
- * This allows limits to be nested. The try/finally ensures that the - * limit is reset if something fails.

- * - *

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.

- * - *

The feature may be disabled in the VM configuration. If so, this - * call has no effect, and always returns -1.

+ * @deprecated This method is now obsolete. */ + @Deprecated public static int setAllocationLimit(int limit) { - return VMDebug.setAllocationLimit(limit); + return -1; } /** - * Establish a global object allocation limit. This is similar to - * {@link #setAllocationLimit(int)} but applies to all threads in - * the VM. It will coexist peacefully with per-thread limits. + * Establish a global object allocation limit. This feature was + * never enabled in release builds. Now that allocation limits + * have been removed this method has no effect. * - * [ The value of "limit" is currently restricted to 0 (no allocations - * allowed) or -1 (no global limit). This may be changed in a future - * release. ] + * @deprecated This method is now obsolete. */ + @Deprecated public static int setGlobalAllocationLimit(int limit) { - if (limit != 0 && limit != -1) - throw new IllegalArgumentException("limit must be 0 or -1"); - return VMDebug.setGlobalAllocationLimit(limit); + return -1; } /**