735
736 julong Arena::_bytes_allocated = 0;
737
738 void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); }
739
740 AllocStats::AllocStats() {
741 start_mallocs = os::num_mallocs;
742 start_frees = os::num_frees;
743 start_malloc_bytes = os::alloc_bytes;
744 start_mfree_bytes = os::free_bytes;
745 start_res_bytes = Arena::_bytes_allocated;
746 }
747
748 julong AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; }
749 julong AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; }
750 julong AllocStats::num_frees() { return os::num_frees - start_frees; }
751 julong AllocStats::free_bytes() { return os::free_bytes - start_mfree_bytes; }
752 julong AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; }
753 void AllocStats::print() {
754 tty->print_cr(UINT64_FORMAT " mallocs (" UINT64_FORMAT "MB), "
755 UINT64_FORMAT" frees (" UINT64_FORMAT "MB), " UINT64_FORMAT "MB resrc",
756 num_mallocs(), alloc_bytes()/M, num_frees(), free_bytes()/M, resource_bytes()/M);
757 }
758
759
760 // debugging code
761 inline void Arena::free_all(char** start, char** end) {
762 for (char** p = start; p < end; p++) if (*p) os::free(*p);
763 }
764
765 void Arena::free_malloced_objects(Chunk* chunk, char* hwm, char* max, char* hwm2) {
766 assert(UseMallocOnly, "should not call");
767 // free all objects malloced since resource mark was created; resource area
768 // contains their addresses
769 if (chunk->next()) {
770 // this chunk is full, and some others too
771 for (Chunk* c = chunk->next(); c != NULL; c = c->next()) {
772 char* top = c->top();
773 if (c->next() == NULL) {
774 top = hwm2; // last junk is only used up to hwm2
775 assert(c->contains(hwm2), "bad hwm2");
|
735
736 julong Arena::_bytes_allocated = 0;
737
738 void Arena::inc_bytes_allocated(size_t x) { inc_stat_counter(&_bytes_allocated, x); }
739
740 AllocStats::AllocStats() {
741 start_mallocs = os::num_mallocs;
742 start_frees = os::num_frees;
743 start_malloc_bytes = os::alloc_bytes;
744 start_mfree_bytes = os::free_bytes;
745 start_res_bytes = Arena::_bytes_allocated;
746 }
747
748 julong AllocStats::num_mallocs() { return os::num_mallocs - start_mallocs; }
749 julong AllocStats::alloc_bytes() { return os::alloc_bytes - start_malloc_bytes; }
750 julong AllocStats::num_frees() { return os::num_frees - start_frees; }
751 julong AllocStats::free_bytes() { return os::free_bytes - start_mfree_bytes; }
752 julong AllocStats::resource_bytes() { return Arena::_bytes_allocated - start_res_bytes; }
753 void AllocStats::print() {
754 tty->print_cr(UINT64_FORMAT " mallocs (" UINT64_FORMAT "MB), "
755 UINT64_FORMAT " frees (" UINT64_FORMAT "MB), " UINT64_FORMAT "MB resrc",
756 num_mallocs(), alloc_bytes()/M, num_frees(), free_bytes()/M, resource_bytes()/M);
757 }
758
759
760 // debugging code
761 inline void Arena::free_all(char** start, char** end) {
762 for (char** p = start; p < end; p++) if (*p) os::free(*p);
763 }
764
765 void Arena::free_malloced_objects(Chunk* chunk, char* hwm, char* max, char* hwm2) {
766 assert(UseMallocOnly, "should not call");
767 // free all objects malloced since resource mark was created; resource area
768 // contains their addresses
769 if (chunk->next()) {
770 // this chunk is full, and some others too
771 for (Chunk* c = chunk->next(); c != NULL; c = c->next()) {
772 char* top = c->top();
773 if (c->next() == NULL) {
774 top = hwm2; // last junk is only used up to hwm2
775 assert(c->contains(hwm2), "bad hwm2");
|