Solved

DLL's: is the memory cleaned?

Posted on 1998-09-21
1
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

696 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