Solved

DLL's: is the memory cleaned?

Posted on 1998-09-21
1
186 Views
Last Modified: 2013-12-27
I am using MATLAB 5.0 on Sun Sparc with Sun OS 4 and call some MEX routines, which are actually in a dinamically linked library. What I am trying to do is to have two MEX functions which are connected by some global variables. The first function initializes the vars, the 2nd one uses them. There are 2 separate calls from MATLAB to each routine. It seems that contents of the global vars are lost after the first call so that when the 2nd functiona attempts to use them it gets garbage. Looks like the library is loaded to and then unloaded from the memory each time it is called. Is there a way around this? Should that be an option for compiler (the MEX funs are written in C and compiled using acc), for MATLAB or for something else?

Thanks
0
Comment
Question by:ilyaz
1 Comment
 
LVL 3

Accepted Solution

by:
braveheart earned 50 total points
ID: 2007057
What do you mean by global variables in this context?  Statics in C?  Common in FORTRAN?

Usually with shared libraries it is necessary to explicitly export such variables for them to be visible by different DLLs. This is because each DLL allocates its own memory for the "global" so the linker has to be told about them to make sure that they share the same memory.

See the ld man pages, particularly the -B family of options.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now