Static memberfunctions in threaded environment.

How does static member functions behave in threaded environment? Do we have to do synchronize explicitly?
Ex:
Calss A{
     Public A(){ };
public static Vector getData()
     // Read data into a Vector object
     return vector object;

I think it depends on the senario. The main purpose of a static method is that any class can use it for similar function without initializing an object of the class that contains the method. It does not prevent threads from creating undesirable results. So, I guess synchronization is still necessary. But if you are using it to return some private static fields which will not be changed by any thread, then it won't be necessary to synchronize it.
PC

Similar Messages

  • Static methods in multi-thread environment.

    Sorry for this silly question, but I have no clue...
    If you're using classes with static methods in a application server environment, would that imply all threads use that same 'one in the jvm' method and would there be a possibility for performance loss?
    Is calling another static method from a static method a good idea in a multi-thread environment, with respect to performance? Somehow I seem to get this java.lang.NoClassDefFoundError. Any ideas? The classes are in the same package. I only get these kind of problems calling static methods from static methods in a multi-thread environmnent. The static methods are pure utility functions and of course do not use class state.
    Thanks for your help.

    Sorry for this question, wasn't thinking straight. I have the answer, won't post question on multiple forums.

  • Using store.sync in threaded environment

    Dear All,
    I just wanted to know what will happen during this condition.
    I have been using berkeley DB java edition for a while.
    I have this environment set
    private Environment myEnv;
    private EntityStore store;
    private PrimaryIndex pk;
    private SecondaryIndex sk;
    EnvironmentConfig myEnvConfig = new EnvironmentConfig();
    myEnvConfig.setAllowCreate(true);
    myEnvConfig.setSharedCache(true);
    myEnv = new Environment(envHome, myEnvConfig);
    StoreConfig storeConfig = new StoreConfig();
    storeConfig.setAllowCreate(true);
    storeConfig.setDeferredWrite(true);
    store = new EntityStore(myEnv, storeName, storeConfig);
    As you can see I have set deferredwrite as true .
    Due to this I have to use sync.store whenever inserts and delete take place.
    I have threaded environment . I just wanted to know .
    Due to the above setting during inserts and delete happening in together will my berkeley db cache ever get corrupted .
    I have not yet seen any issue .
    Is there by any chance cache would be corrupted. Please update me on this
    Regards
    Ashwin

    Ashwin,
    When you use deferred write, you are (a) running without transactions, and (b) reducing your durability guarantee. That is, if the environment goes down, you might lose some portion of the operations you were doing with deferred write.
    (b) only applies when the environment crashes and restarts. I think that you are asking about concurrent reads to the deferred write database while the environment is up. In that case, the issues you have to think about are the same as with regular non-transactional updates. Because you are not using transactions, there is a chance that a reading thread will see data that is logically inconsistent. For example, since you have secondary indices, an insert into the store will result in an insert both into the primary and the secondary index. Since the insert is non transactional, those two updates are not atomic, and another thread may happen to read the primary before the secondary index insert has completed.
    However, you should never see a data record that is physically corrupt. Each data record will be correct, which considered on its own.
    Regards,
    Linda

  • DB_LOCK_DEADLOCK: Using BerkeleyDB Xml in a threaded environment

    Hello,
    I'm having problems running a Berkeley DB application in a threaded environment. In summary, this is what I'm doing:
    I implemented the following class:
    ref class MyTestClass
    private:
         DbEnv* env;
         XmlManager* man;
         unsigned int ctr;
    public:
         MyTestClass()
              ctr = 0;
              env = new DbEnv(0);
              env->set_cachesize(0, 64*1024, 1);
              env->set_lk_max_lockers(1000);
              env->set_lk_max_locks(1000);
              env->set_lk_max_objects(1000);
              env->open("c:\\temp\\SampleDb",
    DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG |
    DB_INIT_MPOOL | DB_INIT_TXN | DB_THREAD | DB_PRIVATE, 0);
              man = new XmlManager(env, DBXML_ALLOW_AUTO_OPEN);
         void MyTestWriter()
              while(true)
                   DbXml::XmlQueryContext *ctx;
                   DbXml::XmlTransaction *txn;
                   DbXml::XmlResults *res;
                   try
                        ctx = new XmlQueryContext(man->createQueryContext(XmlQueryContext::LiveValues, XmlQueryContext::Lazy));
                        txn = new XmlTransaction(man->createTransaction());
                        res = new XmlResults(man->query(*txn, "for $v in collection('test.dbxml')/sessions return insert nodes <A/> into$v", *ctx, DB_RMW));
                        txn->commit(DB_TXN_SYNC);
                   catch(XmlException& e)
                   finally
                        delete res;
                        delete txn;
                        delete ctx;
         void DeadlockUnblocker()
              while(true)
                   int ret;
                   env->lock_detect(0, DB_LOCK_DEFAULT, &ret);
                   Sleep(5000);
    Basically I create a shared MyTestClass object and then spawn 4 threads: 3 of them execute the MyTestWriter method and 1 executes the DeadlockUnblocker method.
    What happens is that the 3 threads block even before completing the first write. After 5 seconds the DeadlockUnblocker is executed and 1 thread is unblocked and throws a "DB_LOCK_DEADLOCK: Locker killed to resolve a deadlock" which is trapped by my catch block. However, the other threads are still hanging on the execution and the entire flow of the application is stopped.
    Anybody can tell me what I'm doing wrong ??
    Thanks
    Matteo

    Matteo,
    First, the C++ API works best if you avoid new/delete of Xml* objects. There are relatively few cases where that's necessary. Using scoped objects ensures their destruction.
    As for your hang the best tool to use is "db_stat -CA" in the environment directory at the time of the hang to find out what is going on. You'll have to not use DB_PRIVATE in the DbEnv::open() flags for it to work. While a deadlock thread is reasonable if you expect a lot of deadlocks (and concurrent write will do that) it is best to use DbEnv::set_lk_detect() to get immediate detection.
    Regards,
    George

  • Multiple Containers read/write access in multi-threaded environment

    I'm been reading the Berkeley DB XML Transaction Processing document and have a few questions. I have a multi-threaded environment (not multi-process).
    1) In the "Summary and Examples" section, there is an example of several worker threads that perform many writes to a shared container. The one container is passed to all the worker threads, rather them having their own instance of the container. In my application, I could potentially have multiple worker threads acting on the same container, is it better to provide some type of connection pool, so each thread has access to the same container? Is their a problem with each thread creating a new instance of the container and writing to that? Is their pros and cons to each approach?
    2) In some specific web applications, they only require read-access and have no intention of writing to the database. If the environment was created with transactions, can these applications open the environment in read-only mode, so as to not suffer the performance penalty of using transactions? Or do they still require transaction support since other threads in other applications might be writing to it. Is it better in this case to
    3) Is there any decent connection pooling framework that work well with BDB XML? If transactions are involved, it seems pretty important to always close the container once you are finished with it, which kind of defeats the purpose of pooling. I see a container somewhat analogous to a JDBC transaction, where in connection pooling these transactions remain open, but in BDB XML, it doesn't seem like this is good practice. So clarification here would be appreciated.
    Thanks in advance...
    Chris

    Chris,
    I'd be careful about trying to draw too many analogies with other sorts of systems. In many ways BDB XML is simpler -- it's just a library, no server process.
    An open container is analogous to an open file handle/descriptor in your operating system. It can safely be shared by all threads within a given process. In fact, you should not create more than one -- while that works, it can just be confusing, and a source of errors (for example, if you use a different path to open the container each time, you'll have problems). So by all means share them. Most Java applications just point them in a class that is accessible to all threads.
    Other objects that can, and should be shared among threads include:
    Environment
    XmlManager
    XmlQueryExpression
    Most others should not. You also mention closing your containers -- there is no reason to close your active container objects until your application needs to shut down. A long-running application will want to use db_checkpoint (or equivalent) to ensure that modified pages are flushed from the transaction log to the database files, but that's about it.
    As for concurrency, you obviously need transactions for concurrent write operations. If you want concurrent read access to the same containers, they should use transactions as well. Even if you don't explicitly use transactions, locks are always taken on pages in transactional containers. You cannot open the same container transactionally and not transactionally at the same time -- bad things could happen.
    Depending on your performance needs, you could using snapshot concurrency, and see how it works for you. While locking does incur some overhead, it may be acceptable.
    You mention creating your own "snapshot" of a container and running read-only on that copy. That's possible to do, but you have to be careful of how you create the snapshot (following hot backup procedures). Also, if you intend to open that "new" container in the same environment or application as the old one, you need to run a program on it to change its internal identification so Berkeley DB won't think it's the same file. That is, you can't just copy a container file to a new name and just open it like it's a new container if it's still in the vicinity of the original. See the -r option for the db_load program.
    Now that you are probably really confused, good luck!
    Regards,
    George

  • Static methods in multi-threaded environment

    Hi,
    I am wondering what happens when several threads try to access the same static method ?
    The static method is not synchronized.
    Will this create any performance issues ?
    The actual scenario is of a J2EE server, where several Session Bean instances try to access a static method in a utility class. Will some session beans have to wait till others are being serviced ?
    thnx n regards
    s giri

    thanx for replying.
    yes. the operations are thread-safe. we do not change the state of any object.
    but we make an rmi call to another application thru this static method.
    is it ok?
    Currently, my session bean has too many private methods - each calling the other application. Due to some quality metrics (a class must be restricted to 700 lines) we have to consider moving these private methods into some Helper class in the form of "public static methods". We have made many utility methods as static, but have some reservations abt doing a similar thing for these methods that call other application.
    regards
    Shivraman

  • Memory leak with multi-threaded environment

    When starting an environment with the THREADED_MUTEXED
    or THREADED_UNMUTEXED mode parameter, the oracle OCCI API
    has a memory leak. This can be demonstrated by modifying
    the "occidml.cpp" demo program as follows:
    Replace line 26:
    env = Environment::createEnvironment (Environment::DEFAULT);
    with
    env = Environment::createEnvironment (Environment::THREADED_MUTEXED);
    And replace line 164:
    demo->displayAllRows();
    with
    for (int ii=0; ii<10000; ii++) demo->displayAllRows();
    Recompile and run the program, and use "top" to see the
    size of the process's used memory continually increase
    unbounded.
    I am using the Oracle 9.2.0.1.0 database on Linux,
    gcc version 2.96.
    Is anyone aware of a fix for this problem?

    Yeah, I did suffer from this.
    If possible , you can switch to using OCCI on Oracle 10G client , you will find no memory leak issue anymore.
    Another issue is that OCCI is using default connection-blocking implementation , if a DB connection is blocked by accident just like plugging out the network link, you can not get any timeout or connection closed indications. You must implement your own OCCI connection timeout strategy, and you must kill the thread/process you are using.

  • Static method,new thread performance question

    Hey guys i just have two questions about two methods used in many controllers/servlets in my app:
    1-what is the difference between calling a static method in a util class or a non static method (like methods dealing with dates i.e getting current time,converting between timezones), which is better ? 2-what is the difference between calling a method(contain too many logic like sending emails) in the controller directly or running this method in a different thread ?

    cs.student wrote:
    Hey guys i just have two questions about two methods used in many controllers/servlets in my app:
    1-what is the difference between calling a static method in a util class or a non static method (like methods dealing with dates i.e getting current time,converting between timezones), which is better ?Depends on the design. It's impossible to say straight why one way would be better than another. Programming isn't that straight forward.
    2-what is the difference between calling a method(contain too many logic like sending emails) in the controller directly or running this method in a different thread ?Threads can be run at the same time. So what you're asking is "what's the difference between doing one thing after another and doing two things at the same time".

  • Instance methods faster than sync. static methods in threaded env?

    consider the following please:
    (-) i have "lots" of instances of a single Runnable class running concurrently..
    (-) each instance uses a common method: "exponential smoothing" and they do a lot of smoothing.
    so:
    (option #1): include a "smooth()" instance method in the Runnable class.
    (option #2): include a "smooth()" synchronized static method in the Runnable class.
    (option #3): create a MathUtility class, and have "smooth()" as an instance method in this class.
    (option #4): make "smooth()" a synchronized static method in the MathUtility class.
    from OOP point of view, i think i should externalize "smooth()" to a MathUtility class, and then make
    is "synchronized static".
    but then from a performance point of view....
    would not it be optimal to make "smooth()" an instance method in MathUtility and then have each
    instance of the Runnable create its own MathUtility instance so that each thread has its own copy
    of the "smooth()" method??
    well, i can't image there would be a measurable difference so maybe i should not post.
    but, if there is a flaw in my thinking, please let me know.
    thanks.

    kogose wrote:
    from OOP point of view, i think i should externalize "smooth()" to a MathUtility class, and then make
    is "synchronized static".From an OOP point of view you should probably have a class that represents the data that provides a (non-static) smooth() method that either modifies the data or returns a new smoothed data object (depending on whether you want your data objects to be immutable or not).
    but then from a performance point of view....
    would not it be optimal to make "smooth()" an instance method in MathUtility and then have each
    instance of the Runnable create its own MathUtility instance so that each thread has its own copy
    of the "smooth()" method??No, methods are not "copied" for each instance. That just doesn't happen.
    well, i can't image there would be a measurable difference so maybe i should not post.If you don't know, then you should probably try it.
    but, if there is a flaw in my thinking, please let me know.The flaw in your thinking is that you can think that you can intuitively grasp the difference in performance of a change at that level.
    I have yet to meet anyone who can reliably do that.
    Performance optimization is not an intuitive task at that level and you should never do performance optimizations without proving that they are improvements for your particular use case.
    First part: Is the smooth() method really thread-unsafe? Does it use some shared state? My guess would be that it uses only local state and therefore doesn't need any synchronization at all. That would also be the fastest alternative, most likely.

  • Are static nested classes thread-safe?

    There doesn't seem to be any definitive answer to this. Given the following code, is it thread-safe?
    public class SomeMultiThreadedWebController {
    public HttpServletResponse someMethodToExecuteViaWebRequest(HttpServletRequest request) {
        simpleQueryBuilder("SELECT...").addParameter("asdf","asdf").createQuery(EMF.getEntityManager()).executeUpdate();
    protected static class SimpleQueryBuilder {
             private String queryString;
             private Map<String, Object> params = new HashMap<String, Object>();
             public SimpleQueryBuilder(String queryString) {
                  this.queryString = queryString;
             public SimpleQueryBuilder addParameter(String name, Object value) {
                  params.put(name, value);
                  return this;
             public Query createQuery(EntityManager em) {
                  Query query = em.createQuery(queryString);
                  for (Entry<String, Object> entry : params.entrySet()) {
                       query.setParameter(entry.getKey(), entry.getValue());
                  return query;
        public static SimpleQueryBuilder simpleQueryBuilder(String queryString) {
             return new SimpleQueryBuilder(queryString);
    }Forget whether or not someone would do this, as this is just an example. I'm really trying to get at whether or not the instance variables inside the static nested class are thread-safe. Thanks for any responses.

    Hello,
    I believe you understand what you're talking about, but you state it in a way that is very confusing for others.
    Let me correct this (essentially, incorrect uses of the terminology):
    I agree that thread-safe or not is for an operation, for a member, it has some sort of contextual confusion.
    Member has a much broader meaning in the [Java Language Specification|http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.4] . Even "class member" applies to both an attribute, a method, or an inner class or interface.
    I think you mean "member variable" of a class (aka "attribute" or "field"). By the way, static or not is irrelevant to the rest of the discussion.
    For an operation or a member, if there's only one thread could access it atomically in one moment, we could call it thread-safe.Mmm. I was tempted to say yes (I'm reluctant to commit myself). With an emphasis on "_The encapsulating class_ makes this member's usage thread-safe".
    Still, just synchronizing each operation on a member is not enough to make all usages "thread-safe":
    Consider a java.util.Vector: each add/get is synchronized, so it is atomic, fine.
    However if one thread adds several values, let's say 3, one by one, to a vector that initially contains 0 values, and another thread reads the vector's size() (another properly synchronized method), the reader thread may witness a size anywhere among 0, 1, 2, 3, which, depending on the business logic, may be a severely inconsistent state.
    The client code would have to make extra work (e.g. synchronizing on the vector's reference before the 3 adds) to guarantee that the usage is thread-safe.
    Thus any synchronized method(With the limit stated above)
    or immutable member (like primitive type) are thread-safe.
    Additionally for a member, if it's immutable, then it's thread-safe. You mean, immutable primitive type, or immutable object. As stated previously, an immutable reference to a mutable object isn't thread-safe.
    a static final HashMap still have thread-safe issue in practice because it's not a primitive.The underlined part is incorrect. A primitive may have thread-safety issues (unless it's immutable), and an object may not have such issues, depending on a number of factors.
    The put, get methods, which will be invoked probably, are not thread-safe although the reference to map is.Yes. And even if the put/get methods were synchronized, the client code could see consistency issues in a concurrent scenario, as demonstrated above.
    Additional considerations:
    1) read/write of primitive types are not necessarily atomic: section [ §17.7 of the JLS|http://java.sun.com/docs/books/jls/third_edition/html/memory.html#17.7] explicitly states that writing a long or double value (2 32-bits words) may not be atomic, and may be subject to consistency issues in a concurrent scenario.
    2) The Java Memory Model explicitly allows non-synchronized operations on non-volatile fields to be implemented in a "thread-unsafe" way by the JVM. Leading way to a lot of unintuitive problems such as the "Double-Checked Locking idiom is broken". Don't make clever guess on code execution path unless you properly synchronize access to variables across threads.
    Edited by: jduprez on Mar 4, 2010 9:53 AM

  • Can volatile variable be called as static variable for threads?

    I am trying to understand volatile variable, and it's uses. I was thinking of using it to make it shared variable between threads, but not between object instances.
    public class VolatileExample extends Thread {
      volatile int x = 1;
      public void f() {
           x++;
           System.out.println(Integer.toString(x));
        public void run() {
              for(int i = 0; i<20;i++){
                   f();
                   try { Thread.sleep(500); } catch(InterruptedException e) {}
        }now, if I create two threads in main method of the same VolatileExample class, say T1 and T2, how many times would volatile int x be instanciated? would there be just one copy of volatile int x created, no matter howmany threads I create?

    WHICH REMINDS ME: YOU DIDN'T ANSWER MY QUESTION AS TO
    WHETHER YOU UNDERSTAND THREADS' LOCAL COPIES OF
    VARIABLES VS. THE MAIN MEM COPYIn my understanding,
    local copies means each thread gets their own copy of a variable and they play with it separately. changing this variable in one thread does not chage value for another thread.
    main mem copy is the one accessed by all the threads. If one thread changes this value, it is reflected to all other threads using this variable.
    right?
    I tried using voaltile variable as shared variable like this:
    import java.io.*;
    public class VolatileIncrement {
      private int x = 1;
      public void f() {
           x++;
           System.out.println(Integer.toString(x));
      public String toString() { return Integer.toString(x); }
      class MakeThread extends Thread{
           public MakeThread(){
                System.out.println("starting MakeThread thread");
         public void run() {
              for(int i = 0; i<20;i++){
                   f();
                   try { Thread.sleep(500); } catch(InterruptedException e) {}
      public void createT() {
         Thread T2 = new MakeThread();
              T2.start();
         Thread T1 = new MakeThread();
              T1.start();
    }and created another class:
    import java.io.*;
    class TestVolatile
         public static void main(String[] args)
              VolatileIncrement vi = new VolatileIncrement();
              System.out.println("creating threads now...");
              vi.createT();
              System.out.println("Done Testing!!");
    }can this be called as correctly using non-static volatile variable as shared data?

  • Static method and threads?

    I have a question regarding "static". for example, I have the following code
    class Test{
    public int i=0;
    public static calculateInt(){
    ....some operations on i;
    if two processes attempt to call Test.calculateInt() at the same time. What will the effects be? shall these two calls be implemented totally independent? each call holds it own "i" for calculation. OR there will be operation conflicit on i.
    what if I change "public i" to :private i", the same effects?

    You can't operate on i in a static method, since i is an instance variable.
    If you make i static, then you can operate on it in a static method. In that case, all threads will share a single i--there's only one i for the whole class, and threads don't change that. Making it private won't change that.
    If you make the method into an instance (non-static) method, then any threads operating on the same instance will share the same i, regardless of whether it's public or private. Different threads operating on different instances will each have their own i.
    Java's Thread Tutorial
    JavaWorld: Introduction to Java threads
    IBM: Introduction to Java threads
    Google: java+threads+tutorial
    Also check out http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ThreadLocal.html

  • Unusual Error in Threaded Environment

    I get a weird error when running my application on a threaded mode. This error however occurs not always but once in a while and that too when I have around 20+ threads. When I have lesser number of threads this error does not occur at all or i could say very very rarely.
    any idea guys
    I am using 11g instant client and 10g database. and this is how my error message goes.
    *** glibc detected *** /home/bala/workspace/OracleTester/OracleTest/Debug/OracleTest: corrupted double-linked list: 0x0845a390 ***
    ======= Backtrace: =========
    /lib/tls/i686/cmov/libc.so.6[0xb61cc3f4]
    /lib/tls/i686/cmov/libc.so.6[0xb61ce207]
    /lib/tls/i686/cmov/libc.so.6(cfree+0x96)[0xb61ce456]
    /opt/oracle/instantclient/instantclient_11_1/libclntsh.so.11.1(sltsmxd+0x34)[0xb68d16b0]
    /opt/oracle/instantclient/instantclient_11_1/libclntsh.so.11.1(ltsmxd+0x37)[0xb6904633]
    /opt/oracle/instantclient/instantclient_11_1/libclntsh.so.11.1[0xb65e46a1]
    /opt/oracle/instantclient/instantclient_11_1/libclntsh.so.11.1(kpufhndl0+0x32a)[0xb65df82a]
    /opt/oracle/instantclient/instantclient_11_1/libclntsh.so.11.1(kpufhndl+0x20)[0xb65df4f6]
    /opt/oracle/instantclient/instantclient_11_1/libclntsh.so.11.1(kpuspsessionrelease+0x111d)[0xb6eed9e5]
    /opt/oracle/instantclient/instantclient_11_1/libclntsh.so.11.1(OCISessionRelease+0xa2)[0xb6d84086]
    and here is my code
    Environment* Genv1; // OCCI environment
    Connection* Gcon1; // OCCI connection
    int const MAX = 50;
    void openConcurrentConnections(void _tgtObject);
    int main(){
    int iRetVal;
    pthread_t thread[MAX];
    pthread_attr_t attr;
    void *status;
    Genv1 = Environment::createEnvironment(Environment::THREADED_MUTEXED);
    /* Initialize and set thread detached attribute */
    pthread_attr_init(&attr);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
    for(int i =0 ;i<MAX;i++){
    iRetVal = pthread_create(&thread, &attr, openConcurrentConnections, (void *)i);
    if (iRetVal) {
    printf("ERROR; return code from pthread_create()is %d\n", iRetVal);
    exit(-1);
    /* Free attribute and wait for the other threads */
    pthread_attr_destroy(&attr);
    for(unsigned short int t=0; t< MAX; t++) {
    iRetVal = pthread_join(thread[t], &status);
    // delete all filereader pointers and set the variable to NULL
    if (iRetVal) {
    printf("ERROR; return code from pthread_join()is %d\n", iRetVal);
    exit(-1);
    printf("Main: completed join with thread %d having a status of %ld\n",t,(long)status);
    Genv1->terminateEnvironment(Genv1);
    printf("Main: program completed. Exiting.\n");
    pthread_exit(NULL);
    void openConcurrentConnections(void _tgtObject){
    Gcon1 = Genv1->createConnection("Ecologital","123","//192.168.1.11:1521/Neurologik");
    cout << "oracle connection OPENED" << endl;
    Genv1->terminateConnection(Gcon1);
    cout << "oracle connection CLOSED" << endl;
    pthread_exit((void*) _tgtObject);

    Hi,
    Have you tried running something like valgrind against this?
    Regards,
    Mark

  • Leak in Threaded environment on Oracle 9.2 /Linux

    I am writing an MT server on Linux which connects to Oracle via OCI (also tried OCCI)
    When I initiate OCI environment with OCI_THREADED, I get a leak in OCIServerAttach.
    Its size increases with the number of statements executed on the connection.
    When I switch to OCI_DEFAULT, leak goes away.
    I have verified that this is reproducible on Oracle's own examples.
    I change the connection option to Encrionment::THREADED_MUTEXED (also tried THREADED_UNMUTEXED)
    in occiproc.cpp and made the procedure call in a loop,
    leak was apparent and was proportional to the number of PL/SQL procedure calls.
    Leak went away when the envrionment option was reset to default.
    The leak is pretty large - about 1K per call, it can be seen from "top",
    and by using valgrind.
    This is quite a shocker. Has anybody observed anything similar or has a similar
    configuration which works flawlessly?
    The compiler I use is gcc 2.96 on Redhat Linux 7.3
    Gene Gorokhovsky
    PS
    Here is a relevant part of valgrind report on 100 repetions of the procedure calls:
    I get similar stacks when I use pure OCI calls bypassing OCCI (OCI layer courtesy of OTL V4)
    ==9494== 119328 bytes in 1243 blocks are definitely lost in loss record 78 of 81
    ==9494== at 0x40042A34: malloc (vg_clientfuncs.c:100)
    ==9494== by 0x40A3A442: sltsmxi (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x405F3B76: snsbitini_ts (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x405DA2E3: nsgbliuc (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x405DA8E6: nsgblini (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x406618A4: niotns (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x4065DAA9: nigcall (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x405FAFF3: osncon (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x40439A63: kpuadef (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x404BCC35: upiini (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x404ABF8B: upiah0 (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x40414026: kpuatch (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x404A010C: OCIServerAttach (in /home/oracle/ora92/lib/libclntsh.so.9.0)
    ==9494== by 0x402A3872: (within /home/oracle/ora92/lib/libocci.so.9.0)
    ==9494== by 0x402A2B81: (within /home/oracle/ora92/lib/libocci.so.9.0)
    ==9494== by 0x402A2855: (within /home/oracle/ora92/lib/libocci.so.9.0)
    ==9494== by 0x804AAEE: (within /home/geneg/project/test/test/test)
    ==9494== by 0x8049E22: main (in /home/geneg/project/test/test/test)
    ==9494== by 0x42017589: (within /lib/i686/libc-2.2.5.so)
    ==9494== by 0x8049C51: __builtin_new (in /home/geneg/project/test/test/test)
    ==9494==
    ==9494== LEAK SUMMARY:
    ==9494== definitely lost: 119328 bytes in 1243 blocks.
    ==9494== possibly lost: 1152 bytes in 12 blocks.
    ==9494== still reachable: 635053 bytes in 195 blocks.
    ==9494== Reachable blocks (those to which a pointer was found) are not shown.

    Hi,
    I have some kind of similar problem, the difference is i use Pro*C 9.2 precompiler from Sun Solaris and Hp clients.
    My program runs in different threads, every thread has its own connection, and executes some SQL statements in an endless loop. Top or prstat shows some 10M memory consumption growth in every second.
    On Windows the problem has not occured.
    I'd also appreciate if enyone could tell me what libraries should be linked into an multithreaded Pro*C program. I tried to compile my program with the demo_proc.mk (under Sun it needs some modifications), but as far as i can see this does not make any difference between single or multithreaded programs.
    As in Gene's case i could reproduce the memory leek with the Oracle's cpdemo1.pc demo program with the small modification of putting the EXEC SQL COMMIT and EXEC SQL SELECT in an endless loop.
    [email protected]
    Zsolt

  • Problem about Sparc/solaris10 signal in multi-thread environment

    Normally if we send a signal to a process which has several threads, the main thread of this process will handle this signal. But I found in some cases an other thread (not main thread) handled signals even if main thread was alive(mostly main thread was being blocked by __pollsys()).
    I want to know why and how this happens.
    Thanks.

    according to man signal.h from a solaris 10 machine ...
    Asynchronously generated signals are not directed to
    a particular thread but are handled by an arbitrary thread
    that meets either of the following conditions:
    .... a list of conditions.
    So if you have threads that you don't want to take signals, then those threads
    must block that signal eg pthread_sigmask()
    it is just chance that it usually goes to your "main" thread.
    tim

Maybe you are looking for

  • What happens to a mail item, Fn-Ctrl-Alt-Del is pressed

    What happens to a mail item, when Fn-Ctrl-Alt-Del is pressed while in the mail tool? I can't seem to find the email file anywhere. Is there a way to disable this key pattern in the mail program?

  • Why won't my iTunes 11 play more than one song at a time?

    Songs appear in "Up Next", but at the end of the song being played they disappear and nothing gets played next. This makes iTunes useless as a music player. Please help.

  • Mail Client?

    I sometimes get the following message when trying to contact some businesses:  Could not perform this operation because mail client is not property installed.  What does this mean, and how do I correct it?  I use the Verizon Message Center.

  • HttpConnection in background and UI thread in front causes lockups !

    Hi , Iam running a midlet on Tre0 600 using IBM J9. (CLDC1.0/MIDP2) The design of the midlet is as follows. I have a main form with some items on it. (items are xml forms) When i select a item (form) fill it and submit, i put the data to be requested

  • Assertion failed error with bonjour

    I am getting and assertion failed error. Here is the actual message microsoft visual c++ Runtime Library Assertion failed! Program:... File:.|mybonjour.cpp line:286 Expression:lerr==knsserviceerrno error Does anyone no what this is? Ever since I star