Skip to content

Commit

Permalink
Improvement CORE-4671 : Release internal temporary blobs early to fre…
Browse files Browse the repository at this point in the history
…e some memory\disk space
  • Loading branch information
hvlad committed Jan 26, 2015
1 parent aaa2936 commit 43f6746
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
19 changes: 18 additions & 1 deletion src/jrd/blb.cpp
Expand Up @@ -246,7 +246,8 @@ blb* blb::create(thread_db* tdbb, jrd_tra* transaction, bid* blob_id)

blb* blb::create2(thread_db* tdbb,
jrd_tra* transaction, bid* blob_id,
USHORT bpb_length, const UCHAR* bpb)
USHORT bpb_length, const UCHAR* bpb,
bool userBlob)
{
/**************************************
*
Expand Down Expand Up @@ -341,6 +342,22 @@ blb* blb::create2(thread_db* tdbb,
page->blp_header.pag_type = pag_blob;
blob->blb_segment = (UCHAR*) page->blp_page;

// Bind non-user blob to the request

jrd_req* request = tdbb->getRequest();
if (!userBlob && request)
{
transaction->tra_blobs->locate(blob->blb_temp_id);
BlobIndex* current = &transaction->tra_blobs->current();

jrd_req* blob_request = request;
while (blob_request->req_caller)
blob_request = blob_request->req_caller;

current->bli_request = blob_request;
current->bli_request->req_blobs.add(blob->blb_temp_id);
}

// Format blob id and return blob handle

blob_id->set_temporary(blob->blb_temp_id);
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/blb.h
Expand Up @@ -98,7 +98,7 @@ class blb : public pool_alloc<type_blb>
void BLB_check_well_formed(thread_db*, const dsc* desc);
void BLB_close(thread_db*);
static blb* create(thread_db*, jrd_tra*, bid*);
static blb* create2(thread_db*, jrd_tra*, bid*, USHORT, const UCHAR*);
static blb* create2(thread_db*, jrd_tra*, bid*, USHORT, const UCHAR*, bool = false);
static Jrd::blb* get_array(Jrd::thread_db*, Jrd::jrd_tra*, const Jrd::bid*, Ods::InternalArrayDesc*);
ULONG BLB_get_data(thread_db*, UCHAR*, SLONG, bool = true);
USHORT BLB_get_segment(thread_db*, void*, USHORT);
Expand Down
2 changes: 1 addition & 1 deletion src/jrd/jrd.cpp
Expand Up @@ -2355,7 +2355,7 @@ JBlob* JAttachment::createBlob(CheckStatusWrapper* user_status, ITransaction* tr
try
{
jrd_tra* const transaction = find_transaction(tdbb);
blob = blb::create2(tdbb, transaction, reinterpret_cast<bid*>(blob_id), bpb_length, bpb);
blob = blb::create2(tdbb, transaction, reinterpret_cast<bid*>(blob_id), bpb_length, bpb, true);
}
catch (const Exception& ex)
{
Expand Down

0 comments on commit 43f6746

Please sign in to comment.