Re: Controlling Memory Usage from JLink
- To: mathgroup at smc.vnet.net
- Subject: [mg107798] Re: Controlling Memory Usage from JLink
- From: "Alexey Popkov" <lehin.p at gmail.com>
- Date: Fri, 26 Feb 2010 04:07:19 -0500 (EST)
- References: <firstname.lastname@example.org> <email@example.com>
"Albert Retey" <awnl at gmx-topmail.de> ÓÏÏÂÝÉÌ/ÓÏÏÂÝÉÌÁ × ÎÏ×ÏÓÔÑÈ ÓÌÅÄÕÀÝÅÅ: news:hm6u03$gij$1 at smc.vnet.net... > My guess here is that you are doing something that needs a lot of > memory, but not _in the Kernel_, and MemoryContrained only controls the > memory usage of the mathematica kernel. You should note that the > Mathematica FrontEnd (the gui you see), many of the import/export > functionalities and some other functionalities are running in separated > processes which use their own share of memory, which can not be > controlled with MemoryConstrained. So could you give an example where > MemoryContrained does (sometimes) fail? My calculation involves solving a system of differential equations by NDSolve in different domains and sometimes (I can not predict) such solution (probably a set of InterpolatingFunctions) takes hudge volume of memory. In such cases I must kill the MathKernel because the computation will go infinite time. I have found a workaround (not ideal): one MathKernel (which may be called "master MathKernel") comands the second MathKernel (which may be called "working MathKernel") to compute the solution for particular set of parameters of the system of differential equations. I do this by a command like LinkWrite[link, Unevaluated[EvaluatePacket[ MemoryConstrained[f[x, y], TOTALMEMORYCONSTRAIN - MemoryInUse, $Failed] ]]] In many cases this works well. But sometimes it looks like that "MemoryConstrained" is just ignored: MathKernel takes a hudge volume of memory and freezes because of swapping. I do not understand why it happens. But I have found some (not elegant) workaround: I use TimeConstrained in the "master MathKernel". It is not very good and obviously proves that MemoryConstrained fails (I am setting the parameter TOTALMEMORYCONSTRAIN knowingly much less the amount of memory available and know (thanks to "Process Explorer" by Sysinternals) that this limitation is in really beated much). My program is not simple but I can send an example if you consider it interesting.