Getting "bad allocation" error in LO 5.0.4.2 Impress

When trying to create a LO Impress family photo album, I got this error message when saving the 18th page. It was not an isolated error, I tried to do this several times. The picture is 9.75 MB in size and the Impress file without it is 81.2 MB in size. A previous family photo album I succeeded in completing is 1.14 GB in size. Tell me what you need to know to help me fix this error or where a tool to supply the information is.

Please try resetting the user profile, sometimes solves strange issues.
https://wiki.documentfoundation.org/UserProfile
Usually it’s enough renaming/deleting the file “user/registrymodifications.xcu”, it affect all the options in Menu/Tools/Options, and the files “user/basic/dialog.xlc” and “scrip.xlc” are overwritten, additionally custom colors in “user/config/standard.soc” are lost.