Wednesday, September 27, 2017

Older ITunes trouble

For various reasons, primarily that of not wanting to shell out hundreds of $ every time a new OS forces paid software App updates, I tend to allow the OS world to pass me by.

In the spring this year I had hardware failure on my Windows PC. So I build a whole new machine. Reinstalled apps, games (geez, turned out I had nearly a terabyte of game files, that took a while). This was on Windows 7; I never upgraded that because 8 was an atrocity, 9 never existed. So a couple months after this new hardware build (btw: 4.5GHz hex-core Intel, 16Gig RAM finally, this time I didn't build a tiny machine), Win 7 updates itself, then says "oh, I don't understand this fancy shmancy new hardware, I can't upgrade myself properly now", and my graphics updates are broken too. That means nearly no games work, and I wonder what else is goofed up...so I will have to upgrade to Windows 10.

I mention all that because Windows isn't nearly as good as OSX about upgrades. In general, in the past, you were better off with a clean wipe and reload from zero. That's time consuming, but probably better for Windows anyway.

OSX was not like that. Is not like that. New versions, if they are going to run on your machine, will install as clean upgrades.

But eventually OSX outgrows your hardware. This means you have to buy new hardware occasionally. So now I'm in the habit of not buying new hardware from Apple. EBay has used machines at great prices. So I've bought some older hardware.

In fact, several older hardwares.

I have a G5 machine, with older apps on it. Expensive Apps. That I can't afford to update again. So that one was also serving as music source, with a fiber cable to my fancy newer hifi that takes optical in. Works great. Runs 10.5, aka Leopard.

About a year ago, got a replacement machine with some newer App versions. That was nice. Came with 10.7 (Lion), the newest/lastest it could take.


Now the ITunes problem. Lion, at least on this machine, has either done something odd about virtual memory (actually another unix partition that you can't see) -- vm partition not big enough -- or ITunes is really flawed. ITunes uses VM partition space (I guess?) while actually playing music, and eventually exhausts it. If you pause music, it stops using space, and resumes when you un-pause. I normally just let it run continuously, and hit the mute button on the hifi remote.

So after a few days, ITunes fills virtual memory, and then it hangs, and OSX Lion says "you are out of application memory" but of course I'm not, it's just ITunes being stupid. This never happened on the G5 machine (and the corresponding software).

So I got a new used machine this month. A 3.5GHz dual-hex-core Mac Pro. Most powerful machine Apple ever made. Cloned the boot disk out of the Lion machine for safety. Installed original into dual-hex. Upgraded to Mountain Lion. Same thing just happened with ITunes--"out of application memory"

At this point the only thing that is the same is that the boot disk that had Lion on it now has Mountain Lion. Otherwise everything else is new. I don't know how to make the swap partition any larger here (at the unix level I could do it easily enough, not actually hard there, but I think that the swap-space is dynamic these days, and my knowledge is from the old static-swap days). This disk reports having 200 GB free. It's an SSD--could that be the cause? Don't know. (This is not a fully updated Mtn Lion, and it's ITunes 12.2. Later: fully updated, with version 12.4. I think 12.7 is the latest, needed for some IPhone 8 stuff.)

So what is going on? Weelllllll.....it's called a memory leak. It's a software bug. The likeliest situation I can think of is that memory is being allocated for the audio data and then not released--audio files are pretty big, and after playing for 60 continuous hours, at roughly 1 megabyte per minute, never de-allocated, ITunes has pushed 3.6 gigabytes into page space, and exhausted what it is allowed to have. OK, it shouldn't be using that much RAM anyway, but it's the de-allocation failure that is the issue. This is just about the oldest software bug there is after indexing off the end of an array in C. I suspect that what has happened here is that ITunes is not properly releasing a pointer to already-played audio data, so it's hogging space, and eventually you're out. (And given how slowly new data is created/released in audio speeds, it's not like the problem about running out of file handles, which is A LOT easier to bump into if you aren't closing files that you've opened--which, I grant you, could also be a problem here, but decent code scanners will warn you about that.) I've been guilty of failing to close open files in my own code, but nothing I've written that had lengthy runtime had that problem (partly because you run out of "file handles" after a bit. A project I called "The Fridge" was a distributed grid engine, and while it was self-recovering if there was a disaster, it really needed to be not ever having the need to. Altho there was this one error on Linux where a shelled sub-process crashed so very hard it would take down the grid engine node; never did figure out what was wrong there, and now I've forgotten what that sub-process was.)

Or, if it's the disk itself, there is something similar going in that space is not getting deallocated properly after use in the swap partition. That could be investigated by cloning this disk back onto a platter drive and using that for a while. I have some other trade-arounds I could do. OTOH, it's only ITunes that is screwing up. You could also imagine this being associated with the optical fiber digital audio out, I've never used that before in my life; at the same time, ITunes for Leopard using optical wasn't doing this.

Also: at some point here soon I'm going to upgrade this machine to Maverick. If there's an ITunes bug still there, one would hope it is gone. But maybe it isn't...

In any case, if you are doing what I am doing and are experiencing this crash on an older OSX, the simples approach is to totally quit ITunes at the end of the day (or first thing in the morning) and restart it. You'll lose your position in whatever playlist you were in, but that beats a full machine reboot...

-----

slightly later: ITunes here seems hurt worse/differently: it reaches a state where it is still playing, but I cannot go to the GUI and do anything. I hid it, and it won't reappear, and "Force Quit" reports is as not responding. I hope it's not the case that that Lion original is messed up, I can't reinstall-from-scratch some of the apps, and I need to use them. Grrr.

Solution: I created an Automator iCal alarm app in which I quit ITunes, wait 30 sec, restart ITunes, and tell it to start playing. That is set to repeat every day at 12.05 am, i.e., right after midnight. That way there's no opportunity to accumulate too much memory-leak trash.

That's gotta be better. I hope that the upgrade to Sierra eventually eliminates this bug.

Later later: the daily reset of ITunes seems to be working, but last night it crashed at some point. This is getting tiresome. Later later: ok, that was a one-time problem, hasn't happened again since.

The old quad-core Pro is slowly dying, so it's powered-down right now. I need to recover what I can there, but the machine is not looking good right now. Ethernet seems to go out, video acts weird after a bit, audio sockets don't work...

------------------------

January 2018: I upgraded to Yosemite (10.10), which includes a newer iTunes and the problem seems to have gone away. Also, the Automator thing seems to not work; fortunately that seems to not matter. I didn't upgrade to Maverick because that doesn't have iPhoto (huh? what sort of stupid was that?)

March 2018: January situation continues to be true--iTunes is not being stupid on me, so I am getting rid of the Automator script.

No comments: