473,695 Members | 2,005 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

mallopt() vs shared library

S S
Hi

I have my shared (.so) library which uses our own memory manager. 32
bit lib was working fine, but when we switched to 64 bit library, as
our own defined small pointer can not handle big addresses. I am
facing trouble as our memory manager do not handle big memory requests
but passes it on to system malloc() and malloc returns out of range
addresses which our small pointer can not accommodate. Whole of the
design is based on that small pointer and hence I can not avoid it.

Out of range addresses are returned due to the fact that malloc
internally uses mmap() call. I tried to disable it using mallopt() but
it is not getting disabled. I am using correct syntax, but I assume
there are some tricks to use it when using with shared library. So,
how to disable mmap() OR ask malloc to return addresses within range
in case of shared library ?

I would highly appreciate any suggestions.

S
Jun 27 '08 #1
2 2626
On May 22, 11:46*am, S S <sarvesh.si...@ gmail.comwrote:
Hi

I have my shared (.so) library which uses our own memory manager. 32
bit lib was working fine, but when we switched to 64 bit library, as
our own defined small pointer can not handle big addresses. I am
facing trouble as our memory manager do not handle big memory requests
but passes it on to system malloc() and malloc returns out of range
addresses which our small pointer can not accommodate. Whole of the
design is based on that small pointer and hence I can not avoid it.

Out of range addresses are returned due to the fact that malloc
internally uses mmap() call. I tried to disable it using mallopt() but
it is not getting disabled. I am using correct syntax, but I assume
there are some tricks to use it when using with shared library. So,
how to disable mmap() OR ask malloc to return addresses within range
in case of shared library ?

I would highly appreciate any suggestions.

I suggest you fix the program to use sufficiently large pointers,
anything else is a hack which will eventually come back to bite you.

All the rest of this is quite outside the scope of standard C++.

Even if you prevented malloc() from calling mmap(), there's nothing at
all preventing malloc() from returning a 64 bit pointer once it runs
out of heap space below 2G or 4G (depending on where your system puts
that line).

That being said, many systems allow a program to be compiled with
options that the entire program uses only 32 bit pointers, but it
sounds like your problem is that the base program is using full sized
pointers, but your shred library is not.

Many system will have some way to allocate memory specifically below
the 4G line, but it'll not be what malloc() calls by default, so you'd
have to write your own allocator. For example, on some *nix, you can
specify MAP_ADDR32 as a flag to mmap(). But you should ask for more
information in a newsgroups dedicated to your system.
Jun 27 '08 #2
S S wrote:
Hi

I have my shared (.so) library which uses our own memory manager. 32
bit lib was working fine, but when we switched to 64 bit library, as
our own defined small pointer can not handle big addresses.
Then you haven't ported your code to 64 bit. 64 bit code uses 64 bit
pointers.

--
Ian Collins.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2196
by: Simon | last post by:
Hello. I wanna use my dynamic shared library(built with C language) with php script. (PHP version is 4.0.6) So I making a shared library(*.so) in Solaris environment(2.7) and it is successful. Php script can load my library successfully. And Now I port my library to HP(HP-UX 11.0) and IBM(AIX 4.1.3) system.
0
2267
by: Phil | last post by:
I realize this is the php group, but I have a question that recurses back to my php install. My objective is a pure 64 bit shared object installation of php 5.0 on UltraSparc Solaris 9 compiled with the Sun Compiler version 8. My problem is that EVERYTHING builds great EXCEPT that the 6b distribution of JPEG will NOT build a shared object, thus gd cannot include support for JPEG, thus php loses that functionality.
1
4418
by: AH | last post by:
I have two functions in my shared library which are declared as follows: void setName(const std::string& str); std::vector<std::string> getInfo(); Since the code is compiled and in shared library. Every thing is great if the customer of my shared library is using the same compiler version (and same STL version). I am wondering if the customer changes their compiler version (or STL version) which may have same interface
7
3353
by: Alexandre | last post by:
Hello, Maybe it's a little OT, but the fact is that I don't necessarly want to know "how to correct?", but "why it happens?" I have a program who "segment fault" (ok, that's "normal"... ;-) but this time, it's not my code who "segment fault" but it's in the call of malloc/mallopt I've got:
2
2035
by: santa19992000 | last post by:
Confusing th eword with "library", "shared library" and how to use these things in real C project, is there any small example I can take a look. Thanks.
7
3393
by: akennis | last post by:
First of all, sorry for duplicating this post. I put it up in the alt.comp.lang.learn.c-c++ mistakenly. I'm investigating a problem whereby exceptions thrown from functions in a Shared Library which was dynamically loaded (dlopen) are not properly caught by the caller. Specifically, when compiling with G++ version 4.0, the RTTI data associated with the exception types is not being properly aligned between the Shared Library and its...
5
475
by: David T. Ashley | last post by:
I've occasionally had trouble compiling and linking programs that use shared libraries. That never made a lot of sense to me, because I thought the operating system went hunting for the symbols and libraries at runtime (and not before). Questions: a)How do the development tools know that a given symbol (a function entry point, for example) is located in a shared library and won't be linked in statically?
3
3222
by: S S | last post by:
Hi Are there some known issues using STL with shared library. Recently I got some crash for which the reason I dont see any, and searching on goolge shown some such issues with shared library. If somebody can help ? Thanks in advance. S
16
3271
by: Xiaoxiao | last post by:
Hi, I got a C library, is there a way to view the public function names in this library so that I can use in my C program? Thanks.
0
8630
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9115
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8845
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7660
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6491
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4579
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3003
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2272
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.