internal/debug: add debug_freeOSMemory (#15122)

This commit is contained in:
Felix Lange 2017-09-11 09:33:18 +02:00 committed by GitHub
parent 10181b57a9
commit 5596b664c4
2 changed files with 67 additions and 70 deletions

View File

@ -176,6 +176,11 @@ func (*HandlerT) Stacks() string {
return string(buf) return string(buf)
} }
// FreeOSMemory returns unused memory to the OS.
func (*HandlerT) FreeOSMemory() {
debug.FreeOSMemory()
}
func writeProfile(name, file string) error { func writeProfile(name, file string) error {
p := pprof.Lookup(name) p := pprof.Lookup(name)
log.Info("Writing profile records", "count", p.Count(), "type", name, "dump", file) log.Info("Writing profile records", "count", p.Count(), "type", name, "dump", file)

View File

@ -34,58 +34,56 @@ var Modules = map[string]string{
const Chequebook_JS = ` const Chequebook_JS = `
web3._extend({ web3._extend({
property: 'chequebook', property: 'chequebook',
methods: methods: [
[ new web3._extend.Method({
new web3._extend.Method({ name: 'deposit',
name: 'deposit', call: 'chequebook_deposit',
call: 'chequebook_deposit', params: 1,
params: 1, inputFormatter: [null]
inputFormatter: [null] }),
}), new web3._extend.Property({
new web3._extend.Property({
name: 'balance', name: 'balance',
getter: 'chequebook_balance', getter: 'chequebook_balance',
outputFormatter: web3._extend.utils.toDecimal outputFormatter: web3._extend.utils.toDecimal
}), }),
new web3._extend.Method({ new web3._extend.Method({
name: 'cash', name: 'cash',
call: 'chequebook_cash', call: 'chequebook_cash',
params: 1, params: 1,
inputFormatter: [null] inputFormatter: [null]
}), }),
new web3._extend.Method({ new web3._extend.Method({
name: 'issue', name: 'issue',
call: 'chequebook_issue', call: 'chequebook_issue',
params: 2, params: 2,
inputFormatter: [null, null] inputFormatter: [null, null]
}), }),
] ]
}); });
` `
const Clique_JS = ` const Clique_JS = `
web3._extend({ web3._extend({
property: 'clique', property: 'clique',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'getSnapshot', name: 'getSnapshot',
call: 'clique_getSnapshot', call: 'clique_getSnapshot',
params: 1, params: 1,
inputFormatter: [null] inputFormatter: [null]
}), }),
new web3._extend.Method({ new web3._extend.Method({
name: 'getSnapshotAtHash', name: 'getSnapshotAtHash',
call: 'clique_getSnapshotAtHash', call: 'clique_getSnapshotAtHash',
params: 1 params: 1
}), }),
new web3._extend.Method({ new web3._extend.Method({
name: 'getSigners', name: 'getSigners',
call: 'clique_getSigners', call: 'clique_getSigners',
params: 1, params: 1,
inputFormatter: [null] inputFormatter: [null]
}), }),
new web3._extend.Method({ new web3._extend.Method({
name: 'getSignersAtHash', name: 'getSignersAtHash',
call: 'clique_getSignersAtHash', call: 'clique_getSignersAtHash',
@ -100,10 +98,9 @@ web3._extend({
name: 'discard', name: 'discard',
call: 'clique_discard', call: 'clique_discard',
params: 1 params: 1
}) }),
], ],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'proposals', name: 'proposals',
getter: 'clique_proposals' getter: 'clique_proposals'
@ -115,8 +112,7 @@ web3._extend({
const Admin_JS = ` const Admin_JS = `
web3._extend({ web3._extend({
property: 'admin', property: 'admin',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'addPeer', name: 'addPeer',
call: 'admin_addPeer', call: 'admin_addPeer',
@ -162,10 +158,9 @@ web3._extend({
new web3._extend.Method({ new web3._extend.Method({
name: 'stopWS', name: 'stopWS',
call: 'admin_stopWS' call: 'admin_stopWS'
}) }),
], ],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'nodeInfo', name: 'nodeInfo',
getter: 'admin_nodeInfo' getter: 'admin_nodeInfo'
@ -177,7 +172,7 @@ web3._extend({
new web3._extend.Property({ new web3._extend.Property({
name: 'datadir', name: 'datadir',
getter: 'admin_datadir' getter: 'admin_datadir'
}) }),
] ]
}); });
` `
@ -185,8 +180,7 @@ web3._extend({
const Debug_JS = ` const Debug_JS = `
web3._extend({ web3._extend({
property: 'debug', property: 'debug',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'printBlock', name: 'printBlock',
call: 'debug_printBlock', call: 'debug_printBlock',
@ -268,6 +262,11 @@ web3._extend({
params: 0, params: 0,
outputFormatter: console.log outputFormatter: console.log
}), }),
new web3._extend.Method({
name: 'freeOSMemory',
call: 'debug_freeOSMemory',
params: 0,
}),
new web3._extend.Method({ new web3._extend.Method({
name: 'memStats', name: 'memStats',
call: 'debug_memStats', call: 'debug_memStats',
@ -358,8 +357,7 @@ web3._extend({
const Eth_JS = ` const Eth_JS = `
web3._extend({ web3._extend({
property: 'eth', property: 'eth',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'sign', name: 'sign',
call: 'eth_sign', call: 'eth_sign',
@ -396,10 +394,9 @@ web3._extend({
}, },
params: 2, params: 2,
inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex] inputFormatter: [web3._extend.formatters.inputBlockNumberFormatter, web3._extend.utils.toHex]
}) }),
], ],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'pendingTransactions', name: 'pendingTransactions',
getter: 'eth_pendingTransactions', getter: 'eth_pendingTransactions',
@ -411,7 +408,7 @@ web3._extend({
} }
return formatted; return formatted;
} }
}) }),
] ]
}); });
` `
@ -419,8 +416,7 @@ web3._extend({
const Miner_JS = ` const Miner_JS = `
web3._extend({ web3._extend({
property: 'miner', property: 'miner',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'start', name: 'start',
call: 'miner_start', call: 'miner_start',
@ -451,7 +447,7 @@ web3._extend({
new web3._extend.Method({ new web3._extend.Method({
name: 'getHashrate', name: 'getHashrate',
call: 'miner_getHashrate' call: 'miner_getHashrate'
}) }),
], ],
properties: [] properties: []
}); });
@ -461,12 +457,11 @@ const Net_JS = `
web3._extend({ web3._extend({
property: 'net', property: 'net',
methods: [], methods: [],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'version', name: 'version',
getter: 'net_version' getter: 'net_version'
}) }),
] ]
}); });
` `
@ -474,8 +469,7 @@ web3._extend({
const Personal_JS = ` const Personal_JS = `
web3._extend({ web3._extend({
property: 'personal', property: 'personal',
methods: methods: [
[
new web3._extend.Method({ new web3._extend.Method({
name: 'importRawKey', name: 'importRawKey',
call: 'personal_importRawKey', call: 'personal_importRawKey',
@ -501,14 +495,13 @@ web3._extend({
name: 'deriveAccount', name: 'deriveAccount',
call: 'personal_deriveAccount', call: 'personal_deriveAccount',
params: 3 params: 3
}) }),
], ],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'listWallets', name: 'listWallets',
getter: 'personal_listWallets' getter: 'personal_listWallets'
}) }),
] ]
}) })
` `
@ -517,12 +510,11 @@ const RPC_JS = `
web3._extend({ web3._extend({
property: 'rpc', property: 'rpc',
methods: [], methods: [],
properties: properties: [
[
new web3._extend.Property({ new web3._extend.Property({
name: 'modules', name: 'modules',
getter: 'rpc_modules' getter: 'rpc_modules'
}) }),
] ]
}); });
` `
@ -633,7 +625,7 @@ web3._extend({
name: 'newMessageFilter', name: 'newMessageFilter',
call: 'shh_newMessageFilter', call: 'shh_newMessageFilter',
params: 1 params: 1
}) }),
], ],
properties: properties:
[ [
@ -669,7 +661,7 @@ web3._extend({
name: 'listmounts', name: 'listmounts',
call: 'swarmfs_listmounts', call: 'swarmfs_listmounts',
params: 0 params: 0
}) }),
] ]
}); });
` `
@ -696,7 +688,7 @@ web3._extend({
status.queued = web3._extend.utils.toDecimal(status.queued); status.queued = web3._extend.utils.toDecimal(status.queued);
return status; return status;
} }
}) }),
] ]
}); });
` `