I have a large document that used to compile well some 3 years ago. I came back to it and every time I try compiling it I get ! TeX capacity exceeded, sorry [save size=50000]. I tried to follow any good ideas, like here or here. The second one didn't help me as I use MiKTeX (I coudn't locate any files like texmf.cnf in MiKTeX). I tried following steps from the first one but either it doesn't work or I'm too stupid for this... (sorry!). I tried executing

to enter extra_mem_top = 2000000 and/or main_memory = 5000000
followed by

however the result remains the very same error.
I am posting a MWE, however it doesn't produce the error. The interesting thing is that my document consists of two large parts. When I compile it including only one part, it compiles well. Same thing when I compile it with the second part only. Just when compiling the whole document (with both large parts included), it produces the error and the build output reads:
Does anyone possibly have an idea how to solve this? It really looks like a memory error, not code error (since the code compiles well when there's only half of it)...
Edit: Strange thing. I can more or less determine the line that produces the error. When I remove that section from the document, the error is produced at the next following section. It looks like that the error is always in the same line, no matter what the content is.
\documentclass[paper=a5,fontsize=10pt,twoside,twocolumn,pagesize,DIV=15,headsepline,titlepage,openright]{scrbook}
\usepackage{scrlayer-scrpage}
\usepackage{cmap}
\usepackage[utf8x]{inputenc}
\usepackage[vietnamese,polish,english,ngerman]{babel}
\usepackage[T5,T1]{fontenc}
\usepackage{longtable}
\usepackage{lmodern}
\newcommand*\de{\fontencoding{T1}\selectfont\selectlanguage{ngerman}}
\newcommand*\en{\fontencoding{T1}\selectfont\selectlanguage{english}}
\newcommand*\pl{\fontencoding{T1}\selectfont\selectlanguage{polish}}
\newcommand*\vn{\fontencoding{T5}\selectfont\selectlanguage{vietnamese}}
\newcommand{\textfsf}{\sffamily\bfseries\selectfont}
\newcommand{\textksf}{\sffamily\itshape\small\selectfont}
\makeatletter
\g@addto@macro\description{\raggedright}
\makeatother
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.8ex plus 0.4ex minus 0.2ex}
\flushbottom
\clearscrheadings
\ihead{}
\chead{}
\ohead{\rightmark}
\ifoot{}
\cfoot{}
\ofoot{\pagemark}
\pagestyle{scrheadings}
\pdfinfo{
/Title (xxx.pdf)
/Creator (xxx)
/Producer (xxx)
/Author (xxx)
/CreationDate (D:20100101000000)
/ModDate (D:20100101000000)
/Subject (xxx)
/Keywords (xxx)
}
\begin{document}
\frontmatter
\title{\pl ZÓŁTA KROWA\\ \vn CHÀO MỪNG}
\subtitle{\pl NA ŁĄCE\\ \vn CÁC BẠN}
\author{\pl dzień\\ \vn tốt}
\date{}
\publishers{\pl Wydawcy}
\maketitle
\mainmatter
\pl tu będzie trochę tekstu \vn vẫn có bằng tiếng Việt \\
\pl tu będzie trochę tekstu \vn vẫn có bằng tiếng Việt \\
\pl tu będzie trochę tekstu \vn vẫn có bằng tiếng Việt \\
\pl tu będzie trochę tekstu \vn vẫn có bằng tiếng Việt \\
\pl tu będzie trochę tekstu \vn vẫn có bằng tiếng Việt \\
\pl tu będzie trochę tekstu \vn vẫn có bằng tiếng Việt \\
\backmatter
\end{document}

vietnameseand I just edited it. What do you mean saying "assigning globally and locally at the same time"? Could it mean that the compiler gets upset because of using the defined\vnand\plover and over again? – Dominik Dec 04 '18 at 16:38undefined control sequenceerrors and thefatal errorthing (that no pdf could be produced). – Dominik Dec 04 '18 at 16:40