blob: ea0510f91dc39e0c30a8c0699aa4ffd9cfab1cc2 [file] [log] [blame]
The Android Open Source Projectf6c38712009-03-03 19:28:47 -08001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16/*
17 * Internal heap functions
18 */
19#ifndef _DALVIK_ALLOC_HEAP
20#define _DALVIK_ALLOC_HEAP
21
22/*
23 * Initialize the GC heap.
24 *
25 * Returns true if successful, false otherwise.
26 */
27bool dvmHeapStartup(void);
28
29/*
30 * Initialization that needs to wait until after leaving zygote mode.
31 * This needs to be called before the first allocation or GC that
32 * happens after forking.
33 */
Carl Shapiroec805ea2010-06-28 16:28:26 -070034bool dvmHeapStartupAfterZygote(void);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080035
36/*
37 * Tear down the GC heap.
38 *
39 * Frees all memory allocated via dvmMalloc() as
40 * a side-effect.
41 */
42void dvmHeapShutdown(void);
43
Carl Shapiroec805ea2010-06-28 16:28:26 -070044/*
45 * Stops any threads internal to the garbage collector. Called before
46 * the heap itself is shutdown.
47 */
48void dvmHeapThreadShutdown(void);
49
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080050#if 0 // needs to be in Alloc.h so debug code can find it.
51/*
52 * Returns a number of bytes greater than or
53 * equal to the size of the named object in the heap.
54 *
55 * Specifically, it returns the size of the heap
56 * chunk which contains the object.
57 */
58size_t dvmObjectSizeInHeap(const Object *obj);
59#endif
60
Carl Shapirod25566d2010-03-11 20:39:47 -080061typedef enum {
62 /* GC all heaps. */
63 GC_FULL,
64 /* GC just the first heap. */
65 GC_PARTIAL
66} GcMode;
67
68typedef enum {
Barry Hayes1b9b4e42010-01-04 10:33:46 -080069 /* Not enough space for an "ordinary" Object to be allocated. */
70 GC_FOR_MALLOC,
Carl Shapiroec805ea2010-06-28 16:28:26 -070071 /* Automatic GC triggered by exceeding a heap occupancy threshold. */
72 GC_CONCURRENT,
Barry Hayes1b9b4e42010-01-04 10:33:46 -080073 /* Explicit GC via Runtime.gc(), VMRuntime.gc(), or SIGUSR1. */
74 GC_EXPLICIT,
75 /* GC to try to reduce heap footprint to allow more non-GC'ed memory. */
76 GC_EXTERNAL_ALLOC,
77 /* GC to dump heap contents to a file, only used under WITH_HPROF */
78 GC_HPROF_DUMP_HEAP
Carl Shapirod25566d2010-03-11 20:39:47 -080079} GcReason;
Barry Hayes1b9b4e42010-01-04 10:33:46 -080080
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080081/*
82 * Run the garbage collector without doing any locking.
83 */
Carl Shapiro29540742010-03-26 15:34:39 -070084void dvmCollectGarbageInternal(bool clearSoftRefs, GcReason reason);
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080085
Carl Shapiroec47e2e2010-07-01 17:44:46 -070086/*
87 * Blocks the until the GC thread signals the completion of a
88 * concurrent GC.
89 */
90void dvmWaitForConcurrentGcToComplete(void);
91
The Android Open Source Projectf6c38712009-03-03 19:28:47 -080092#endif // _DALVIK_ALLOC_HEAP