Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
ef227c5f
Unverified
Commit
ef227c5f
authored
Feb 12, 2021
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: fix temp memory blowup caused by defers holding on to state
parent
111abdcf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
1 deletion
+12
-1
blockchain.go
core/blockchain.go
+12
-1
No files found.
core/blockchain.go
View file @
ef227c5f
...
@@ -1805,6 +1805,17 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
...
@@ -1805,6 +1805,17 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
return
it
.
index
,
err
return
it
.
index
,
err
}
}
// No validation errors for the first block (or chain prefix skipped)
// No validation errors for the first block (or chain prefix skipped)
var
activeState
*
state
.
StateDB
defer
func
()
{
// The chain importer is starting and stopping trie prefetchers. If a bad
// block or other error is hit however, an early return may not properly
// terminate the background threads. This defer ensures that we clean up
// and dangling prefetcher, without defering each and holding on live refs.
if
activeState
!=
nil
{
activeState
.
StopPrefetcher
()
}
}()
for
;
block
!=
nil
&&
err
==
nil
||
err
==
ErrKnownBlock
;
block
,
err
=
it
.
next
()
{
for
;
block
!=
nil
&&
err
==
nil
||
err
==
ErrKnownBlock
;
block
,
err
=
it
.
next
()
{
// If the chain is terminating, stop processing blocks
// If the chain is terminating, stop processing blocks
if
bc
.
insertStopped
()
{
if
bc
.
insertStopped
()
{
...
@@ -1867,7 +1878,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
...
@@ -1867,7 +1878,7 @@ func (bc *BlockChain) insertChain(chain types.Blocks, verifySeals bool) (int, er
}
}
// Enable prefetching to pull in trie node paths while processing transactions
// Enable prefetching to pull in trie node paths while processing transactions
statedb
.
StartPrefetcher
(
"chain"
)
statedb
.
StartPrefetcher
(
"chain"
)
defer
statedb
.
StopPrefetcher
()
// stopped on write anyway, defer meant to catch early error returns
activeState
=
statedb
// If we have a followup block, run that against the current state to pre-cache
// If we have a followup block, run that against the current state to pre-cache
// transactions and probabilistically some of the account/storage trie nodes.
// transactions and probabilistically some of the account/storage trie nodes.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment