Date: Sat, 9 Mar 2013 17:19:29 -0800 From: Mehmet Erol Sanliturk <m.e.sanliturk@gmail.com> To: mexas@bristol.ac.uk Cc: freebsd-questions@freebsd.org Subject: Re: how to forbid a process to use swap? Message-ID: <CAOgwaMsUzV-CYTD4M-Fc1xNuXu6WnVRLgg28qHzL8pDZHbchXA@mail.gmail.com> In-Reply-To: <201303100030.r2A0UjoS058395@mech-cluster241.men.bris.ac.uk> References: <CAOgwaMtBN%2BLxA5k0zQTbjdM%2BjmWuNT58UYp5eX7cbqPnFbhKfA@mail.gmail.com> <201303100030.r2A0UjoS058395@mech-cluster241.men.bris.ac.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Mar 9, 2013 at 4:30 PM, Anton Shterenlikht <mexas@bristol.ac.uk>wrote: > From m.e.sanliturk@gmail.com Sun Mar 10 00:25:27 2013 > > On Sat, Mar 9, 2013 at 3:55 PM, Anton Shterenlikht < > mexas@bristol.ac.uk>wrote: > > > I run a program that uses large arrays. > > I don't want it to use swap, because it's > > too slow. I want the program to fail when > > there's not enough RAM, rather than using > > swap. How to do this? > > > > Is it something to do with these kernel > > variables: > > > > kern.dfldsiz: 34359738368 > > kern.dflssiz: 8388608 > > > > kern.maxdsiz: 34359738368 > > kern.maxssiz: 536870912 > > kern.maxtsiz: 134217728 > > > > Many thanks > > > > Anton > > > > > > If you have program source , you may do the following : > > > > Define a constant : Maximum_Allocatable_Memory = ? > > > Define a variable : Total_Allocated_Memory = 0 > > > > Before allocating a memory of size M , > check whether Total_Allocated_Memory + M < > Maximum_Allocatable_Memory > > If yes : Allocate memory ; > Add M to Total_Allocated_Memory . > > If no : > > Return an error and gracefully stop your program instead of a > crash which > will loose data . > > It's a fortran program. I'm not very stong in C. > Ideally I'd just use the OS (shell) means, > but I need to understand better which resourse > limit controls what. > > For example, with sh limits(1), I see: > > $ limits > Resource limits (current): > cputime infinity secs > filesize infinity kB > datasize 524168 kB > stacksize 524168 kB > coredumpsize infinity kB > memoryuse infinity kB > memorylocked 64 kB > maxprocesses 12200 > openfiles 117594 > sbsize infinity bytes > vmemoryuse infinity kB > pseudo-terminals infinity > swapuse infinity kB > $ > > Which of these are relevant to my case? > > Finally, the actual problem is on linux, > but I hope if I'm able to understand how > things work on FreeBSD, then I could do > it on linux too, especially if it's just > a sh command. > > Thanks > > Anton > It is not necessary to know C for the above steps . If you have source and if it is compilable by Fortran 90 or later standard , it may use allocation . ( Please see ALLOCATABLE , ALLOCATE , DEALLOCATE in a Fortran >= 90 manual ). I am compiling Fortran 77 programs with respect to 2003 standart by specifying lines as "fixed" by G95 which it is available in FreeBSD also ( www.g95.org ) . It may be necessary to convert Hollerith format specifiers to apostrophes . Personally I do not any idea about the above parameters . You may use "System Monitor" or "top" to see memory usage . If there is no sufficient memory , you may not start your program , or it starts to swap you may kill suitable programs , etc. . Thank you very much . Mehmet Erol Sanliturk
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOgwaMsUzV-CYTD4M-Fc1xNuXu6WnVRLgg28qHzL8pDZHbchXA>