Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This 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.


  Search this Thread
Old 02-05-2013, 07:31 AM   #1
LQ Newbie
Registered: Aug 2011
Posts: 10

Rep: Reputation: Disabled
How to force the memory in user mode to be allocated and locked?

Dear sir,

I use malloc() to allocate a 20MB memory in user mode and use mlock() to lock the memory.
But when I try to find the physical address mapping of the memory, it seems that some pages are not allocated yet. How can I allocate 20MB memory in user mode and make sure the memory is allocated physical memory and is locked?

Thanks for your kindly help!

Old 02-05-2013, 07:59 AM   #2
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
Does it make any difference if you write random data to the 20MB you've allocated?
Old 02-05-2013, 10:28 AM   #3
Senior Member
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,704

Rep: Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270Reputation: 1270
The physical address will be irrelevant - it is unusable for any purpose other than physical I/O handled by drivers. The only case I know of where a single segment is reserved is for some video cards - and that memory has to be removed from the kernels view of memory before it even starts.

Your problem isn't "locked in memory", the 20MB will be scattered all over... there will be different mapping list, not a single address.

And yes, memory is NOT allocated until it is actually used.

It would be a good idea to say what you are trying to do. Maybe we could help then.

Last edited by jpollard; 02-05-2013 at 10:30 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Memory map or physical address of some memory allocated by malloc demon007 Programming 1 02-04-2012 06:17 AM
memcached using more than allocated memory mahmoud Linux - Software 0 05-24-2011 10:15 AM
java uses more than the allocated memory dinakumar12 Linux - Server 6 08-19-2010 04:17 AM
[SOLVED] Memory leak: How risky not to free allocated memory. kaz2100 Linux - General 1 12-24-2008 12:00 AM
About allocated memory in C++ Ephracis Programming 2 12-28-2004 02:56 AM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:49 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration