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.

72 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.

#36 ispoofer key on 06.27.19 at 6:35 am

I conceive you have mentioned some very interesting details , appreciate it for the post.

#37 synapse x cracked on 06.27.19 at 9:24 pm

Respect to website author , some wonderful entropy.

#38 strucid hacks on 06.28.19 at 8:00 am

Me like, will read more. Thanks!

#39 advanced systemcare 11.5 serial on 06.28.19 at 1:54 pm

I love reading through and I believe this website got some genuinely utilitarian stuff on it! .

#40 cryptotab hack script free download 2019 on 06.29.19 at 8:49 am

Thanks for this web. I definitely agree with what you are saying.

#41 check cashed v3 download on 07.01.19 at 9:32 am

I kinda got into this post. I found it to be interesting and loaded with unique points of interest.

#42 tinyurl.com on 07.01.19 at 3:30 pm

Can you tell us more about this? I'd love to find out some additional information.

#43 fortnite cheats on 07.01.19 at 8:16 pm

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

#44 free cheats for rust on 07.02.19 at 8:14 am

I like this website its a master peace ! Glad I found this on google .

#45 nonsense diamond on 07.02.19 at 1:41 pm

I am glad to be one of the visitors on this great website (:, appreciate it for posting .

#46 vn hax download on 07.03.19 at 7:50 am

Great, this is what I was browsing for in yahoo

#47 cyberhackid on 07.03.19 at 7:46 pm

Thank You for this.

#48 prison life hacks on 07.04.19 at 7:47 am

Deference to op , some superb selective information .

#49 seo tutorial step by step with example on 07.04.19 at 2:57 pm

Parasite backlink SEO works well :)

#50 subbot on 07.04.19 at 7:34 pm

I like this site, useful stuff on here : D.

#51 dego pubg hack on 07.05.19 at 7:48 am

You got yourself a new follower.

#52 tom clancy's the division hacks on 07.05.19 at 8:05 pm

bing bring me here. Thanks!

#53 gx tool apk pubg uc hack download on 07.06.19 at 11:25 am

Intresting, will come back here more often.

#54 rekordbox torrent download on 07.06.19 at 11:22 pm

Awesome, this is what I was browsing for in google

#55 call of duty black ops 4 license key generator on 07.07.19 at 9:15 am

I truly enjoy looking through on this web site , it holds superb content .

#56 spyhunter 5.4.2.101 key on 07.08.19 at 9:20 am

I dugg some of you post as I thought they were very beneficial invaluable

#57 quest bars cheap 2019 coupon on 07.09.19 at 5:51 am

What's up it's me, I am also visiting this web site regularly, this web page is
actually fastidious and the users are in fact sharing good
thoughts.

#58 fps unlocker on 07.09.19 at 11:04 am

Cheers, here from google, i enjoyng this, I come back again.

#59 Lesangent on 07.09.19 at 6:19 pm

Prix Du Cialis En Pharmacie En France Mail Order Stendra Internet Cod Only Next Day Delivery [url=http://hxdrugs.com]п»їcialis[/url] Generique Cialis Meilleur Prix Dilantin

#60 how to get help in windows 10 on 07.17.19 at 9:00 am

hello there and thank you for your info – I have certainly picked up
something new from right here. I did however expertise some technical issues using this site, as
I experienced to reload the web site a lot of
times previous to I could get it to load properly.
I had been wondering if your web host is OK? Not that I'm complaining, but slow loading instances times will often affect your placement in google
and can damage your high quality score if advertising and marketing with Adwords.
Well I'm adding this RSS to my email and could look out for a lot more of
your respective exciting content. Make sure you update this again soon.

#61 how to get help in windows 10 on 07.18.19 at 5:46 am

What's Happening i am new to this, I stumbled upon this I've
discovered It positively helpful and it has helped me out loads.
I am hoping to give a contribution & aid different
customers like its aided me. Great job.

#62 Marquis Ursiak on 07.18.19 at 7:45 pm

Skyking, Skyking, this message is your next piece of data. Please contact the agency at your convenience. No further information until next transmission. This is broadcast #5771. Do not delete.

#63 plenty of fish dating site on 07.19.19 at 9:15 am

Wow, fantastic blog layout! How long have you been blogging for?
you make blogging look easy. The overall look of your site
is great, as well as the content!

#64 Lesangent on 07.21.19 at 5:14 am

Cialis Ou Viagra Forum [url=http://xzanax.com][/url] Viagra E Cardioaspirina

#65 how to hack prodigy on 07.21.19 at 3:30 pm

Deference to op , some superb selective information .

#66 natalielise on 07.23.19 at 6:43 am

Stunning story there. What occurred after?

Thanks! plenty of fish natalielise

#67 evogame.net/wifi on 07.23.19 at 1:49 pm

I really enjoy examining on this website , it has got great goodies .

#68 plenty of fish dating site on 07.23.19 at 5:40 pm

I'm not sure where you are getting your info, but good topic.
I needs to spend some time learning more or understanding
more. Thanks for wonderful information I was looking for this information for my mission.

#69 plenty of fish dating site on 07.24.19 at 8:39 am

What's up to all, the contents existing at this site are in fact amazing for people experience, well, keep up the nice work fellows.

#70 forza horizon 4 crack on 07.24.19 at 2:06 pm

Enjoyed reading through this, very good stuff, thankyou .

#71 ezfrags on 07.25.19 at 4:09 pm

I truly enjoy looking through on this web site , it holds superb content .

#72 skisploit on 07.26.19 at 5:15 pm

Respect to website author , some wonderful entropy.