From 5338bcb15703d95bb040347b314cd132004a1a4e Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Wed, 2 Dec 2009 16:02:58 +0100 Subject: [PATCH] Do not free the input / output buffers to avoid consing and memory fragmentation when reading long strings. --- src/c/alloc_2.d | 2 ++ src/c/read.d | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/src/c/alloc_2.d b/src/c/alloc_2.d index df51232..1f9a49f 100644 --- a/src/c/alloc_2.d +++ b/src/c/alloc_2.d @@ -70,6 +70,8 @@ out_of_memory(size_t requested_bytes) int method = 0; if (!interrupts) ecl_disable_interrupts_env(the_env); + /* Free the input / output buffers */ + the_env->string_pool = Cnil; #ifdef ECL_THREADS /* The out of memory condition may happen in more than one thread */ /* But then we have to ensure the error has not been solved */ diff --git a/src/c/read.d b/src/c/read.d index e239853..cbe80ad 100644 --- a/src/c/read.d +++ b/src/c/read.d @@ -82,6 +82,11 @@ si_put_buffer_string(cl_object string) l = TOKEN_STRING_FILLP(ECL_CONS_CAR(pool)); } if (l < ECL_MAX_STRING_POOL_SIZE) { + /* Ok, by ignoring the following code, here we + * are doing like SBCL: we simply grow the + * input buffer and do not care about its + * size. */ +#if 0 if (TOKEN_STRING_DIM(string) > 32*ECL_BUFFER_STRING_SIZE) { /* String has been enlarged. Cut it. */ #ifdef ECL_UNICODE @@ -90,6 +95,7 @@ si_put_buffer_string(cl_object string) string = ecl_alloc_adjustable_base_string(ECL_BUFFER_STRING_SIZE); #endif } +#endif TOKEN_STRING_FILLP(string) = l+1; env->string_pool = CONS(string, pool); } -- 2.9.0