(Yet another) The iTunes Library file cannot be saved

I've seen variations of this for several years, on both Mac & Windows and numerous versions of iTunes, but have something new to ask/add:

I've recently been updating the comments on my m4a/mp3 library using three external apps to add dynamic range, lyrics and key information. Some of this information wasn't immediately displayed in iTunes, so I set to forcing iTunes to read this info with a simple .UpdateInfoFromFile operation for all items in the iTunesApp.BrowserWindow.SelectedTracks collection. Now if I do this on batches that are greater than 1500 tracks, iTunes crashes with a 'The iTunes Library file cannot be saved' error and fails to save the amendments; however, if I keep the batches smaller, then I am successful as long as I close iTunes after each batch - trying to do two batches of 1200 in a row seems to effectively act as if I'm doing 2400 (for example). Generally iTunes is handling my library fairly well, though it does occasionally irretrievably delete the odd track (that cannot be found with the likes of Recuva) when synching to my iPod Classic, so it is backed-up regularly - but that's another issue.

Now, I've been watching what iTunes is doing with Windows Resource Monitor, and I can see that it is successfully reading/writing tmp files in the library's location, my pagefile.sys, the C:\Windows\SysWoW64, the Mft and in my AppData folder, so it appears to have sufficient privileges where required, but I have yet to catch it attempting to do anything specific when it fails, and I rather suspect that it is more related to iTunes inability to cope with the size of the request (or subsequent requests). I may well run ProcMon.exe to see if I can spot anything further.

Some details: Windows 10 Home 64-bit and iTunes 10.7.0.21 (the last decent iTunes before Apple really set about ruining the UI without actually adding any benefits whatsoever IMHO) and I've got 500GB of space on my Music drive and 70GB in my OS drive, and 32GB of RAM.

So, any clues? Am I wasting my time trying to find the root cause, as it's a failing of iTunes itself, and should I just persevere with doing things in smaller chunks?

One other thought: am I programmatically able to force iTunes to save its library, i.e. to emulate the shutdown process, every 1000 amendments?


Posted on Feb 12, 2025 03:35 AM

Reply

Similar questions

2 replies

Feb 13, 2025 04:44 PM in response to turingtest2

Thanks for the reply tt2. Firstly, I forgot to include that the error was the good old 'An unknown error occurred(-50).

I'd disabled my AV and malware programs and also turned off search indexing - I'd read a lot of the previous posts on the topic from over the last few years, so I'd started with the usual suspects.

I'd kinda done the 'wait element' by stopping it and the restarting manually a short time later, once I'd selected another batch (so a good 30-40 seconds delay for the system to settle) - see my note about doing two batches of 1200 (I didn't explicitly state that I didn't shut iTunes down between these two - sorry).

I had a mere 2090 songs left to update, so I selected those and set Windows ProcMon running again, also watching the Resource Monitor. When it inevitably crashed, I could see from the Resource monitor that it was only reading from the Music library - not an exact science, as it averages out read/write load, but it does however help us humans not to miss things :-) .

Nothing jumped out of the Windows system/error logging either.

I then set about scouring the ProcMon logs, to see if any needle jumped out of the haystack, and I spotted one potential issue that appeared to happen just around the time it threw the error (iTunes continued to write events, so it was a bit of guesswork at the exact second). If I filtered to the 'Process Profiling' operation, I spotted that the memory use (?) had suddenly peaked (for iTunes.exe) with it jumping from a normal max of around 'Private Bytes: 1,010,106,368' to 'Private Bytes: 1,595,568,128'. I was actually hoping to see an overly large .tmp file being created, but it never seemed to 'get out of hand' (for want of a more technical expression).

This was the last few minutes (of a 30 minute or so run) before it threw the error:

Now, I can honestly say that a) I may be clutching at straws, and b) I don't really know what those figures relate to without doing some reading (see below*), but they do stand out to me, but I will try some more testing to prove my gut feeling that iTunes throws a wobbly internally if given too many successive changes without a break.

*Private Bytes refer to the amount of memory that the process executable has asked for - not necessarily the amount it is actually using.

They are "private" because they (usually) exclude memory-mapped files (i.e. shared DLLs). But - here's the catch - they don't necessarily exclude memory allocated by those files. There is no way to tell whether a change in private bytes was due to the executable itself, or due to a linked library. Private bytes are also not

exclusively physical memory; they can be paged to disk or in the standby page list (i.e. no longer in use, but not paged yet either)

...

Private Bytes are a reasonable approximation of the amount of memory your executable is using and can be used to help narrow down a list of potential candidates for a memory leak; if you see the number

growing and growing constantly and endlessly, you would want to check that process for a leak. This cannot, however, prove that there is or is not a leak.

turingtest2 wrote:

Do you have any third party security software? This can disrupt the way that iTunes saves the library. Can you add some wait elements in your script to allow iTunes to do some housekeeping before you fire another batch of requests at it?

tt2


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

(Yet another) The iTunes Library file cannot be saved

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.