Keep heap memory in RAM

Hi all,
I am working in Linux (RHL, ver. 2.6) at the application layer. I have to work on large chunks of data (have to dynamically allocate about 500 MB). I want to make sure that this dynamically allocated memory is always present in the RAM, i.e. not swapped out. Does Linux provides any APIs for this purpose?

Thanks for any help.

Comments

  • : Hi all,
    : I am working in Linux (RHL, ver. 2.6) at the application layer. I
    : have to work on large chunks of data (have to dynamically allocate
    : about 500 MB). I want to make sure that this dynamically allocated
    : memory is always present in the RAM, i.e. not swapped out. Does
    : Linux provides any APIs for this purpose?
    :
    : Thanks for any help.
    :

    Why would you want that?
    And what if the computer doesn't have that much ram?
  • : : Hi all,
    : : I am working in Linux (RHL, ver. 2.6) at the application layer. I
    : : have to work on large chunks of data (have to dynamically allocate
    : : about 500 MB). I want to make sure that this dynamically allocated
    : : memory is always present in the RAM, i.e. not swapped out. Does
    : : Linux provides any APIs for this purpose?
    : :
    : : Thanks for any help.
    : :
    :
    : Why would you want that?
    : And what if the computer doesn't have that much ram?

    I can image a couple of scientific calculations, which would need so much memory to contain all the data needed for the calculation. But most of them can be written to make use of the divide-and-conquer technique, so the memory needs can be lessened by smart programming.
  • I have two live video streams flowing in. I want to process each and every frame of the video at real-time. There is a delay between the two streams. The delay may be of about three or five frames (or may be more). So I have implemented a circular queue to account for the delay. And I think, to account for the delay I cannot implement means other than a circular buffer (or can I?).
    The frames I get are uncompressed YUV frames and they can be full HD. So I want to make sure that all the memory I allocate to save the frames in the queue always remain in the RAM so that swapping them doesn't slows things down.
    I hope I am clear in my explanation. And concerning the RAM in the system, I have a dedicated system to serve only this process and the system has 4GB of RAM. So, I am hoping that I have adequate memory.
  • : Hi all,
    : I am working in Linux (RHL, ver. 2.6) at the application layer. I
    : have to work on large chunks of data (have to dynamically allocate
    : about 500 MB). I want to make sure that this dynamically allocated
    : memory is always present in the RAM, i.e. not swapped out. Does
    : Linux provides any APIs for this purpose?
    :
    : Thanks for any help.
    :

    with mlock you can lock ram areas
    see man mlock
  • : : Hi all,
    : : I am working in Linux (RHL, ver. 2.6) at the application layer. I
    : : have to work on large chunks of data (have to dynamically allocate
    : : about 500 MB). I want to make sure that this dynamically allocated
    : : memory is always present in the RAM, i.e. not swapped out. Does
    : : Linux provides any APIs for this purpose?
    : :
    : : Thanks for any help.
    : :
    :
    : with mlock you can lock ram areas
    : see man mlock
    :

    Thanks Tharem, IDK and zibadian.
    mlock worked really fine. It is a very useful API provided by Linux to solve real-time problems.

    Going by the replies of IDK and zibadian, I feel that the method I am using is probably not a widely used one. But based on my requirements (I have described it in my last post), I felt this is the best way to go. If you think that I can have a better solution to my requirements, I will be glad to hear from you. :-)
    Thanks again.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories