static void binary_protocol_flush_buffer (BinaryProtocolBuffer *buffer) { g_assert (buffer->index > 0); fwrite (buffer->buffer, 1, buffer->index, binary_protocol_file); sgen_free_os_memory (buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL); }
static void free_major_section (GCMemSection *section) { DEBUG (3, fprintf (gc_debug_file, "Freed major section %p (%p-%p)\n", section, section->data, section->end_data)); sgen_free_internal_dynamic (section->scan_starts, (section->size + SGEN_SCAN_START_SIZE - 1) / SGEN_SCAN_START_SIZE * sizeof (char*), INTERNAL_MEM_SCAN_STARTS); sgen_free_os_memory (section, MAJOR_SECTION_SIZE); --num_major_sections; }
void sgen_free_internal_dynamic (void *addr, size_t size, int type) { if (!addr) return; if (size > allocator_sizes [NUM_ALLOCATORS - 1]) sgen_free_os_memory (addr, size, SGEN_ALLOC_INTERNAL, MONO_MEM_ACCOUNT_SGEN_INTERNAL); else mono_lock_free_free (addr, block_size (size)); }
void sgen_free_internal_dynamic (void *addr, size_t size, int type) { if (!addr) return; if (size > allocator_sizes [NUM_ALLOCATORS - 1]) { sgen_free_os_memory (addr, size, SGEN_ALLOC_INTERNAL); return; } mono_lock_free_free (addr); }
void sgen_free_internal_dynamic (void *addr, size_t size, int type) { if (!addr) return; if (size > allocator_sizes [NUM_ALLOCATORS - 1]) sgen_free_os_memory (addr, size, SGEN_ALLOC_INTERNAL); else mono_lock_free_free (addr); MONO_GC_INTERNAL_DEALLOC ((mword)addr, size, type); }
void sgen_free_internal_dynamic (void *addr, size_t size, int type) { int index; if (!addr) return; if (size > allocator_sizes [NUM_ALLOCATORS - 1]) return sgen_free_os_memory (addr, size); index = index_for_size (size); mono_lock_free_free (addr); }
static BinaryProtocolBuffer* binary_protocol_get_buffer (int length) { BinaryProtocolBuffer *buffer, *new_buffer; retry: buffer = binary_protocol_buffers; if (buffer && buffer->index + length <= BINARY_PROTOCOL_BUFFER_SIZE) return buffer; new_buffer = (BinaryProtocolBuffer *)sgen_alloc_os_memory (sizeof (BinaryProtocolBuffer), (SgenAllocFlags)(SGEN_ALLOC_INTERNAL | SGEN_ALLOC_ACTIVATE), "debugging memory"); new_buffer->next = buffer; new_buffer->index = 0; if (InterlockedCompareExchangePointer ((void**)&binary_protocol_buffers, new_buffer, buffer) != buffer) { sgen_free_os_memory (new_buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL); goto retry; } return new_buffer; }
void sgen_free_pinned (SgenPinnedAllocator *alc, void *addr, size_t size) { LargePinnedMemHeader *mh; if (!addr) return; if (size <= freelist_sizes [SGEN_PINNED_FREELIST_NUM_SLOTS - 1]) { int slot = slot_for_size (size); free_from_slot (alc, addr, slot); return; } mh = (LargePinnedMemHeader*)((char*)addr - G_STRUCT_OFFSET (LargePinnedMemHeader, data)); g_assert (mh->magic == LARGE_PINNED_MEM_HEADER_MAGIC); g_assert (mh->size == size + sizeof (LargePinnedMemHeader)); /* FIXME: do a CAS */ large_pinned_bytes_alloced -= mh->size; sgen_free_os_memory (mh, mh->size); }
static void binary_protocol_flush_buffer (BinaryProtocolBuffer *buffer) { ssize_t ret; size_t to_write = buffer->index; size_t written = 0; g_assert (buffer->index > 0); while (written < to_write) { ret = write (binary_protocol_file, buffer->buffer + written, to_write - written); if (ret >= 0) written += ret; else if (errno == EINTR) continue; else close_binary_protocol_file (); } current_file_size += buffer->index; sgen_free_os_memory (buffer, sizeof (BinaryProtocolBuffer), SGEN_ALLOC_INTERNAL); }