Уменьшено потребление памяти

This commit is contained in:
Aren Elchinyan 2024-01-21 19:26:01 +03:00
parent d8e5d5f081
commit 90cf91ee31
2 changed files with 28 additions and 6 deletions

View File

@ -14,12 +14,12 @@
#include <stdint.h>
#include <tool.h>
static char start_buffer[8192];
static char start_buffer[1024];
static char *log_buffer;
static uint64_t fb_pos_x = 4;
static uint64_t fb_pos_y = 0;
static uint64_t buf_pos = 0;
static uint64_t buf_max = 8192;
static uint64_t buf_max = 1024;
#define FONT_WIDTH 6 + 1
#define FONT_HEIGHT 8 + 1
@ -120,8 +120,10 @@ void log_init_mem( ) {
(((SCREEN_WIDTH - 4) / FONT_WIDTH) * (SCREEN_HEIGHT / FONT_HEIGHT)) / 1024);
log_buffer = mem_alloc(((SCREEN_WIDTH - 4) / FONT_WIDTH) * (SCREEN_HEIGHT / FONT_HEIGHT));
tool_memcpy(log_buffer, start_buffer, 4096);
tool_memcpy(log_buffer, start_buffer, buf_max);
buf_max = ((SCREEN_WIDTH - 4) / FONT_WIDTH) * (SCREEN_HEIGHT / FONT_HEIGHT);
LOG("Размер буффера: %u символов\n", buf_max);
redraw_screen( );
}
void log_init( ) {

View File

@ -60,16 +60,36 @@ void mem_dump_memory( ) {
while (curr) {
if (curr->next) {
LOG("->0x%x | %u килобайт | %s | 0x%x\n", &curr->data, (curr->size) / 1024,
LOG("->0x%x | %u мегабайт | %s | 0x%x\n", &curr->data, (curr->size) / 1024 / 1024,
curr->free ? memory_types[0] : memory_types[1], curr->next);
} else {
LOG("->0x%x | %u килобайт | %s | Это последний блок\n", &curr->data, (curr->size) / 1024,
LOG("->0x%x | %u мегабайт | %s | Это последний блок\n", &curr->data, (curr->size) / 1024 / 1024,
curr->free ? memory_types[0] : memory_types[1]);
}
curr = curr->next;
}
}
void mem_get_stat( ) {
size_t free_mem = 0;
size_t used_mem = 0;
struct mem_entry *current_entry = first_node;
while (current_entry) {
if (current_entry->free) {
free_mem += current_entry->size;
} else {
used_mem += current_entry->size;
}
current_entry = current_entry->next;
}
LOG("Свободно: %u мегабайт\n", free_mem / 1024 / 1024);
LOG("Занято: %u мегабайт\n", used_mem / 1024 / 1024);
}
void mem_check_dynamic_memory( ) {
mem_entry_t *curr = first_node;
uint64_t free_mem = 0;
@ -250,7 +270,7 @@ void mem_init( ) {
mmmap_count = memmap_response->entry_count;
struct limine_memmap_entry **mmaps = memmap_response->entries;
// LOG("Записей в карте памяти: %u\n", memmap_response->entry_count);
LOG("Записей в карте памяти: %u\n", memmap_response->entry_count);
// Обработка каждой записи в карте памяти
for (uint64_t i = 0; i < mmmap_count; i++) {