sfsam / Itsycal

Itsycal is a tiny calendar for your Mac's menu bar. http://www.mowglii.com/itsycal
MIT License
3.35k stars 234 forks source link

Memory leak #54

Closed Diego999 closed 6 years ago

Diego999 commented 7 years ago

Hi,

When I check the memory consumption in the activity monitor, I can observe that Isycal take around 1.9 Gb. There is clearly a memory leak.

What can we do to fix this ?

Thank you very much !

sfsam commented 7 years ago

@Diego999 Can you provide a screenshot? Thanks.

Diego999 commented 7 years ago

@sfsam Sure, I will do it a little bit later. I just start my laptop up (~15Mb of memory) and I see that the memory of Itsycal is increasing every few second (by few 0.x Mb, in 2' it reaches 40Mb) which can explain yesterday why at the end of the day I was around 2Gb.

I take a screenshot when it is around 1 Gb.

Thank you for your former answer !

EDIT: Here after ~15' (~9:30) image

Here at 12:05 image

Here at 14:15 image

Diego999 commented 7 years ago

@sfsam Here finally the 2.5 Gb I talked before

image

Diego999 commented 7 years ago

@sfsam could you reproduce the memory leak ?

sfsam commented 7 years ago

@Diego999 I haven't been able to reproduce it. Mine has been running for 34 days since April 19 and it uses about 34MB of memory:

screen shot 2017-05-23 at 12 29 14 pm

Can you describe more about your setup?

Diego999 commented 7 years ago

@sfsam Thank you for your answer. I reinstall Itsycal to be sure (it was updated last time from before last release) and it seems that the memory is stable after few minutes. I guess it will last.

For the system, I have a Macbook Pro Retina 15" mid-2015 with Sierra 10.12.5

EDIT: I confirm that this fixes the problem. Maybe there was a problem during the update ?

lucianosantana commented 7 years ago

@Diego999 was this solution definitive for you ? I've also reinstalled and it didn't solve. Itsycal starts using 35MB and ends up eating up to 3GB.

My computer is the same Macbook Pro Retina 15" mid-2015 but I have installed OS X 10.12.6

Any chance the issue gets opened again @sfsam ?

Diego999 commented 7 years ago

Hi @lucianosantana

Yes the issue was definitely solved. I'm also running on OS X 10.12.6 and don't have the problem. I don't know how you reinstalled it, but in my case I did it from source rather from the zip file.

Did you already get this problem after an update ?

lucianosantana commented 7 years ago

I've just downloaded the file from the website. You've downloaded the source code and compiled it yourself ?

Diego999 commented 7 years ago

Yes. It may be worth to try.

lucianosantana commented 7 years ago

Hi ! I've never had time to test compiling myself. Now I've tried but I have issue with signing, since I'm not a OS X / iOS developer. To be honest I believe it should work out of the box with the file dowloaded from the site. I haven't been using Itsycal ever since, that's unfortunately the best solution I've found so far.

HankVanZile commented 7 years ago

I am experiencing the same issue. Reinstalling the software did not affect the problem.

macrookie commented 7 years ago

I have the same issue. Removed the application and reinstalled last night (v0.11.6) and I was at 6GB of memory usage this morning.

kabdelrahman commented 6 years ago

I can relate to this issue. It has been leaking memory even on macOS Sierra and currently leaking in macOS High Sierra. Checkout this screenshot. I just killed it.

ltsycal
sfsam commented 6 years ago

Here's what I have so far on this leak:

What did I miss?

Going forward, it's not necessary to provide more screenshots of Activity Monitor showing CPU and memory use as this behavior is well established. Any info on specific triggers or configurations that pertain to this behavior would be appreciated.

Is there some commonality about the nature of certain users' calendar events? My own calendar events are pretty simple so maybe that's why I can't reproduce this bug. It might also explain why the bug disappears for some people: eventually those events go out of scope. This is a wild guess.

Does the Console log output show unusual activity when memory usage is growing?

kabdelrahman commented 6 years ago

@sfsam I will be gathering spindump from my mac couple of times a day just to try to pin the issue down, I will share all files to the ticket once I am done for today at least

kabdelrahman commented 6 years ago

Those are some logs from today. I hope they would help to pin the issue. ltsycal-2017-11-16.zip

sfsam commented 6 years ago

Update: this test version does not appear to resolve this bug

I've put together a test version of Itsycal that might address the memory leak. I still have no idea what is causing it, so this is a shot in the dark. I've had one user test it so far with promising results.

https://s3.amazonaws.com/itsycal/Itsycal-test.zip

Please let me know if it makes a difference.

kabdelrahman commented 6 years ago

@sfsam I will try it for a week and let you know my findings. If similar memory leaks occurred do you think providing a spindump would help?

sfsam commented 6 years ago

@kabdelrahman Thanks for taking a look. I don't really know how to use the spindump output to debug, but it might be interesting just the same. My hope is always that someone with more knowledge than I have will take a look at the data/code and figure out what it happening. Maybe something obvious will be apparent in the difference in spindumps between these two versions.

kabdelrahman commented 6 years ago

@sfsam I believe this version is better than the previous one, so far. It took a longer time to reach 1GB of Real Memory. I noticed that when Locking/Unlocking and Sleep/Wake the memory start climbing and eventually stop at a new mark. I don't know if that would help but worth sharing.

Note I do locking/unlocking and sleep/wake +10 times in a day.

Attached spindump from today. ltsycal.zip

bubbafat commented 6 years ago

Using 0.11.8 on MacOS 10.13.3 I can reproduce it 100% of the time by connecting to a calendar which is synched to Outlook/Exchange via the calendar app. Every time I click on Itsycal to show my upcoming meetings, memory usage by about 10MB on the display and again when hiding. If I remove my Outlook calendar and only connect to gmail/etc - there is no memory leak.

I would say my computer freezes every 2-3 weeks because of this (virt memory can get over 50GB) - I have to send a sigkill to kill it (sigterm is not enough).

sfsam commented 6 years ago

@bubbafat If this is the case, it would explain why I still cannot reproduce this issue. I only have Google calendars. This bug has been driving me crazy. Do you also see high CPU usage?

bubbafat commented 6 years ago

Yes - basically 100%. My laptop is a brick for several minutes and then becomes functional again (until the next time I interact with ityscal).

bubbafat commented 6 years ago

On my side, it appears to be related to this line:

https://github.com/sfsam/Itsycal/blob/dcd47b37a3b233b77fce3a9b23584a8f6f1b9f7b/Itsycal/AgendaViewController.m#L373

With 10+ Outlook events, it allocates 3+ MiB every time the daily agenda is rendered and they are never cleaned up (I'm using the Leaks tool in Instruments on a private build to test this).

This is viewWillAppear -> reloadData -> dimEventsIfNecessary

sfsam commented 6 years ago

@bubbafat Are you saying the leak is in -dimEventsIfNecessary? If you put a return statement immediately after the opening { of that method so that it does nothing, does the leak go away?

borna761 commented 6 years ago

I don't know if it is too early to say, but it looks like the latest version (0.11.9) has solved my memory leak issues.

erikw commented 6 years ago

In 0.11.9 the problem seems to be gone. It uses about 45MB memory for me, compared to 700-800 MB in the previous version.

vviikk commented 6 years ago

I can confirm that this error occurs when I sync Exchange calendars as well.

kabdelrahman commented 6 years ago

👍, I believe this fix making the app stable and not consuming much memory, for me < 50MB, so great work. I think we can close the issue now.

macrookie commented 6 years ago

I can also confirm that this issue was resolved for me after installing 0.11.9. Stable memory usage below 50MB when syncing 5or6 calendars (iCloud, Google, Exchange). Thank you!

bubbafat commented 6 years ago

Also seems to be fixed on my side. Thanks!

vviikk commented 6 years ago

Fixed. Nice work. No more leaks even when using Exchange.

sfsam commented 6 years ago

I believe this issue has been fixed. 🤞