mirror of
https://github.com/varun-r-mallya/sysprof.git
synced 2025-12-31 20:36:25 +00:00
Avoid mallocs in process_sample()
This commit is contained in:
2
TODO
2
TODO
@ -23,6 +23,8 @@ Before 1.0.4:
|
||||
|
||||
Before 1.2:
|
||||
|
||||
* Kernel binary when available, is better than kallsyms.
|
||||
|
||||
* Hack around gtk+ bug where it mispositions the window.
|
||||
|
||||
* Counters must not be destroyed during tracker setup. They have to exist
|
||||
|
||||
11
tracker.c
11
tracker.c
@ -885,6 +885,7 @@ process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
||||
{
|
||||
const context_info_t *context = NULL;
|
||||
const char *cmdline;
|
||||
uint64_t stack_addrs[256];
|
||||
uint64_t *resolved_traces;
|
||||
process_t *process;
|
||||
StackNode *n;
|
||||
@ -907,8 +908,11 @@ process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
||||
len = 4;
|
||||
for (n = sample->trace; n != NULL; n = n->parent)
|
||||
len++;
|
||||
|
||||
resolved_traces = g_new (uint64_t, len);
|
||||
|
||||
if (len > 256)
|
||||
resolved_traces = g_new (uint64_t, len);
|
||||
else
|
||||
resolved_traces = stack_addrs;
|
||||
|
||||
len = 0;
|
||||
for (n = sample->trace; n != NULL; n = n->parent)
|
||||
@ -946,7 +950,8 @@ process_sample (state_t *state, StackStash *resolved, sample_t *sample)
|
||||
|
||||
stack_stash_add_trace (resolved, resolved_traces, len, 1);
|
||||
|
||||
g_free (resolved_traces);
|
||||
if (resolved_traces != stack_addrs)
|
||||
g_free (resolved_traces);
|
||||
}
|
||||
|
||||
Profile *
|
||||
|
||||
Reference in New Issue
Block a user