How to make a heap profiler

I have a new blog post at embeddedrelated.com describing heapprof, a 250-line heap profiler (C+Python) working out of the box on Linux, and easy to port/tweak.

35 comments ↓

#1 Sergey on 05.23.14 at 3:43 am

You can rewrite reduce(operator.or_, [set(block.stack) for block in blocks]) as {x for block in blocks for x in block.stack} which is both shorter and more obvious to understand IMO.

#2 Yossi Kreinin on 05.23.14 at 3:49 am

Actually, yeah – thanks, changed it.

#3 Sergey on 05.23.14 at 9:35 am

You seem to have switched the `for`s around. I agree the order you used would be more intuitive, but that's not the python syntax unfortunately:

>>> [a for a in b for b in [[1]]]
Traceback (most recent call last):
File "", line 1, in
NameError: name 'b' is not defined
>>> [a for b in [[1]] for a in b]
[1]

#4 Yossi Kreinin on 05.23.14 at 9:45 am

Um, yeah… fixed.

#5 Zeev Tarantov on 05.23.14 at 11:31 am

Why do you compile C without optimizations?

#6 Yossi Kreinin on 05.23.14 at 6:32 pm

Erm… do you ask because there's a bug exposed under -O3 or some such?

#7 Joachim Schipper on 06.10.14 at 11:11 pm

This looks cool (and inspires me to take another look at adding backtraces to our memory allocation). One question, though: isn't pulling in threads – and thus possibly a thread-aware standard library, etc. – scary?

#8 Yossi Kreinin on 06.11.14 at 2:41 am

If your app doesn't have threads you don't need to worry about it. If it does you already have a thread-aware stdlib etc. – and the code I spent on threading inside the profiler is not that much code. So I don't think it's particularly troublesome.

#9 warframe aimbot on 05.15.19 at 4:33 pm

Cheers, here from yanex, i enjoyng this, i will come back again.

#10 Angelica Hasenfuss on 05.15.19 at 6:06 pm

5/15/2019 Appreciate yosefk.com– extremely easy to navigate and much to consider!

#11 how to get help in windows 10 on 05.28.19 at 5:11 pm

You ought to be a part of a contest for one of the highest quality websites online.
I'm going to highly recommend this web site!

#12 gamefly free trial on 05.28.19 at 11:30 pm

Excellent way of explaining, and nice paragraph
to get facts concerning my presentation topic,
which i am going to deliver in institution of higher education.

#13 gamefly free trial on 05.30.19 at 2:39 am

When I initially commented I clicked the "Notify me when new comments are added" checkbox and now each time
a comment is added I get three e-mails with the same comment.

Is there any way you can remove me from that service? Bless you!

#14 how to get help in windows 10 on 05.30.19 at 6:31 am

Wow, this piece of writing is nice, my younger sister is analyzing
these things, so I am going to tell her.

#15 gamefly free trial on 06.02.19 at 4:22 pm

Pretty! This was an extremely wonderful post.
Thank you for providing this info.

#16 Dinah Pallotta on 06.03.19 at 4:43 pm

yosefk.com does it yet again! Very thoughtful site and a good post. Keep up the good work!

#17 gamefly free trial on 06.04.19 at 1:11 am

Yes! Finally something about gamefly free trial.

#18 gamefly free trial on 06.04.19 at 6:34 am

It's going to be end of mine day, but before ending I am reading
this enormous piece of writing to improve my know-how.

#19 gamefly free trial on 06.05.19 at 9:53 pm

You really make it seem so easy with your presentation but I find this topic to be really something that I think I would
never understand. It seems too complex and
extremely broad for me. I am looking forward for
your next post, I will try to get the hang
of it!

#20 gamefly free trial on 06.06.19 at 5:09 pm

Link exchange is nothing else however it is simply placing the other person's website link on your page at appropriate place and
other person will also do similar for you.

#21 gamefly free trial on 06.07.19 at 5:45 pm

It is truly a nice and helpful piece of info.
I am glad that you shared this useful information with us.
Please stay us informed like this. Thank you for sharing.

#22 download games on ps4 on 06.07.19 at 6:45 pm

I all the time used to study article in news papers but now as I am
a user of internet therefore from now I am using net for content, thanks to
web.

#23 gamefly free trial 2019 coupon on 06.10.19 at 5:14 pm

Yesterday, while I was at work, my sister stole my apple ipad and tested to see if it can survive a
twenty five foot drop, just so she can be a youtube
sensation. My apple ipad is now broken and she has 83 views.

I know this is entirely off topic but I had to share it with someone!

#24 quest bars cheap on 06.14.19 at 3:25 pm

Ahaa, its fastidious dialogue concerning this paragraph here at this weblog, I have read all that, so
now me also commenting at this place.

#25 quest bars cheap on 06.15.19 at 8:17 am

Hi everyone, it's my first visit at this web page, and paragraph is in fact fruitful in support of me, keep up posting these types of content.

#26 vn hax on 06.17.19 at 2:18 am

yahoo got me here. Thanks!

#27 proxo key on 06.19.19 at 10:24 am

Very interesting points you have remarked, appreciate it for putting up.

#28 vn hax pubg mobile on 06.20.19 at 7:10 pm

Hello, google lead me here, keep up great work.

#29 nonsense diamond key on 06.21.19 at 8:23 am

Good, this is what I was searching for in google

#30 plenty of fish dating site on 06.22.19 at 9:13 am

If some one wants to be updated with hottest technologies
then he must be visit this web site and be up to date everyday.

#31 star valor cheats on 06.23.19 at 5:49 pm

Enjoyed reading through this, very good stuff, thankyou .

#32 gx tool apk download on 06.24.19 at 3:51 pm

Deference to op , some superb selective information .

#33 Explain Like I’m Five on 06.25.19 at 5:45 am

Hi, bing lead me here, keep up nice work.

#34 fortnite mods on 06.25.19 at 8:32 pm

Ha, here from bing, this is what i was looking for.

#35 krunker aimbot on 06.26.19 at 7:11 am

stays on topic and states valid points. Thank you.

Leave a Comment