이 페이지는 기계 번역되었습니다. 영어 원본을 읽어보세요. English

IBSurgeon 라이브러리

Firebird가 많은 메모리를 소비하게 만드는 방법은?

때때로 Firebird 프로세스가 많은 RAM을 소비하는 경우가 있습니다.

여기에는 3가지 주요 이유가 있습니다. 참고로 이것은 권장 사항이 아닙니다 :) 프로덕션 환경에서는 실행하지 마세요!

1. 페이지 버퍼를 너무 높게 설정

예를 들어, firebird.conf에서 SuperServer의 경우

DefaultDbCachePages = 500000M # pages

Firebird를 재시작하고 연결을 시도하면 “Unable to allocate memory from the operating system” 오류 메시지가 표시됩니다:

isql -user SYSDBA -pass masterkey localhost:e:\temp\blob30.fdb Statement failed, SQLSTATE = HY001 unable to allocate memory from operating system -IProvider::attachDatabase failed when loading mapping cache Use CONNECT or CREATE DATABASE to specify a database SQL>

SuperClassic 또는 Classic에서 상대적으로 많은 수의 페이지 버퍼를 사용하는 다중 연결의 경우에도 다음 공식에 따라 동일한 결과가 발생합니다:

페이지 버퍼 수 X 연결 수 X 페이지 크기.

2. 임시 BLOB에 대한 대규모 작업으로 인해 Firebird 프로세스 크기가 커질 수 있음

다음 스크립트를 실행해 보세요 (프로덕션 환경에서는 실행하지 마세요):

create generator g1; set generator g1 to 0; execute block as declare variable blb BLOB; declare variable icnt integer; begin icnt=0; while (icnt <100000000) DO begin select cast('1234567890qwertyuiopasdfghjklzxcvbnm' as BLOB) from rdb$database into :blb; select gen_id(g1,1) from rdb$database into :icnt; end end;

또는 아이디어의 또 다른 변형

create or alter procedure BLOB_LOOP returns ( ATEXT blob sub_type text ) as begin while (true) do begin atext = '123'; suspend; end end

그리고 다음 쿼리는 모든 메모리를 소비합니다 (프로덕션 환경에서 실행하지 마세요!)

select count(*) from blob_loop

3. Classic 및 SuperClassic의 경우 isql.exe의 연결 문자열에 많은 수의 페이지 버퍼를 지정할 수 있으며, 이 연결에 대해 할당됩니다

페이지 버퍼가 헤더 페이지에 명시적으로 설정되지 않은 경우 (즉, 0과 같은 경우)

`C:\FB\30Cs>echo set list on; set stat on; select mon$page_buffers from mon$database; | isql -c 98765 /:e30 -user foo -pas bar Database: /:e30, User: FOO SQL> MON$PAGE_BUFFERS 98765 Current memory = 869314176 Delta memory = 75760 Max memory = 869334512 Elapsed time= 0.001 sec Buffers = 98765 Reads = 3 Writes = 0 Fetches = 42 SQL>

set bail on; set term ^; execute block as declare n int = 10; declare c int; declare my_password varchar(20) = ‘bar’; begin while (n>0) do begin execute statement ‘select 1 from rdb$database’ on external ’localhost:’ || rdb$get_context(‘SYSTEM’, ‘DB_NAME’) as user current_user password my_password role lpad(’’, 20, replace(uuid_to_char(gen_uuid()),’-’,’’)) into c; n = n - 1;`

end

end

^

set term ;^

set list on;

select count(distinct(t.mon$attachment_id)) as num_of_attachments, sum(t.mon$memory_used) as sum_memo_used, sum(t.mon$memory_allocated) as sum_memo_allocated

from (

select

a.mon$attachment_id

,m.*

from mon$attachments a

join mon$memory_usage m on a.mon$stat_id = m.mon$stat_id

where mon$user = current_user

) t;

=======