473,513 Members | 2,576 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 2614
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
2172
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
2259
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...
1
4400
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...
7
3338
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
2016
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
3373
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...
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...
3
3193
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
3257
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
7178
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7397
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. ...
0
7565
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7128
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...
0
7543
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5103
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...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
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
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.