Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6149049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:23:16+00:00 2026-05-23T19:23:16+00:00

I want to allocate virtually contiguous range memory so that I can use the

  • 0

I want to allocate virtually contiguous range memory so that I can use the locality property (spatial locality) when accessing data, with consideration for better performance. I found out at the following page that I need to use vmalloc for better memory locality access (please correct me if I am wrong and have to use kmalloc instead).

What is the difference between vmalloc and kmalloc?

I downloaded the vmalloc package from http://www2.research.att.com/~gsf/cgi-bin/download.cgi?action=list&name=vmalloc

I followed the installation procedure for building the libmalloc.a static library from the source files, and then I copied the generated libvmalloc.a library to /usr/local/lib and /usr/lib directory on my mac.

In my C program, I tried to include the vmalloc.h header file through various approaches as follow:

#include <vmalloc.h>

.

#include <linux/vmalloc.h>

.

#include "vmalloc.h"

but none of them worked. I always got the vmalloc.h: No such file or directory error message.
I used -L/usr/local/lib -lvmalloc flags when compiling my C++ program.
I also got the same error when trying the same thing on my desktop computer (under CentOS operating system).
Here is my makefile:

SHELL = /bin/sh
PROJECT = hw2

TARGET = mkhashtbl
CFLAGS = -O3
LFLAGS = -O3 -L/usr/local/lib -lvmalloc

TFILE = $(PROJECT).tgz
ZFILE = $(PROJECT).zip
PACKFILES = Makefile hashtbl.h hashtbl.c mkhashtbl.c timer.c

all:    $(TARGET)

run:    all
    - ./$(TARGET)

I also tried to modify my Linker flags as follows:

LFLAGS = -O3 -L/usr/local/lib -lvmalloc

and I still got the same error.
What could be wrong in this case? Is there anything wrong in the way I linked the library, or does vmalloc only work for some versions of Linux? If it is the latter case, I am sure that I should still be able to at least include the header file.

EDIT

My real problem is actually the following:

hashtbl_cache *    hashTable_cache;             /* Hash table cache */

    int i;
    hashTable_cache = (hashtbl_cache*)malloc(tbl_size* sizeof(hashtbl_cache));

    for( i = 0 ; i < tbl_size; i++ )
    {
          hashTable_cache[i]. ht_elements = (hashelt_cache*)malloc( hashTable->data_total_size[i] * sizeof(hashelt_cache) ) ;
    }     

I want to make sure that all the ht_elements in every cache are created in order. I read from a forum that vmalloc is good for creating cache aware application, as data are created in virtual memory. Is there any other approach to make sure that the allocation of all elements of my cache array are created in contiguous order, hence will enable me to do a fast lookup? One more thing, the size of every elements in every cache is not the same, so I guess using calloc is not a solution, but I may be wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:23:17+00:00Added an answer on May 23, 2026 at 7:23 pm

    Nemo’s comment should have been given as an answer:

    The vmalloc in that question is a Linux kernel function. Unless you are hacking the kernel or writing a device driver, it is not relevant to you. The vmalloc at the AT&T Research site is something else entirely. Neither one does what you think it does. Just use malloc.

    It’s obvious that you don’t know what “virtually contiguous range” means or you’d realize that malloc must give you that; otherwise it would not work at all.

    Premature optimization is the root of all evil. Especially when you don’t have any idea what the optimization you’re trying to make means.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to allocate more memory to program.l What is the gcc flag that
I want to allocate memory using malloc and check that it succeeded. something like:
i want to allocate 1gb of memory of ipad (or iphone) out of total
Why would you ever want to use alloca() when you could always allocate a
I want to use a temp directory that will be unique to this build.
Is it correct to allocate memory for an array that is set as a
I want to create some memory to use for DMA transfers. (Using Linux 2.6.18-128.el5
How can I allocate more threads per task from TPL? I want to investigate
I want to make an etag that matches what Apache produces. How does apache
How can I determine the address in memory of the Java heap for a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.