Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I want to use mlock to lock portions of my application process into memory, so it doesn't get swapped out. I would like to "mlock" the text segement, data segment, BSS segment and heap segment of my application process - how do I find the start address and length of each of these 4 segments of my application process?
Don't try to do that ... anyway, you can't. An application can "wire" a few pages into memory, maybe, but you can't make an entire application non-swappable.
If you're worried about this sort of thing .. buy more RAM, and/or run fewer applications in the system. Or impose "ulimit"s on what the individual applications can potentially allocate.
The system will never steal a page unless it's been reduced to stealing in order to survive. If you can demonstrate that your application is being adversely affected by swapping, then the root cause to be dealt-with is not a microscopic one but a much bigger picture.
At install time you get prompted to define a swap partition (or logical volume if you lean that way). After installation while running normally you remove the swap line from /etc/fstab and reboot. You now have a spare partition you can repurpose.
Then all your processes will refrain from any paging/swapping with no extra effort.
Thanks for all of the advice. At this point, I'm only interested in locking/pinning certain segments of an applicaiton into memory using the mlock function. However, I'm not sure how to find out the starting address and length of each segment. It appears to be available in kernel space via the mm_struct, but not sure how to access that information in the application itself?
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.