Memory management while implementing JNI interfaces.

The assumption here is that java code calls a C function from a
shared library in Linux.
How should memory management be done in the native code called
from Java using a JNI interface?
What role does the Garbage Collector play in handling memory that
was allocated in the native C code?
If I allocate memory using malloc() in the C program, should I
explicitly free it? Will the GC take care of it?
Does anyone have an idea of how memory management be done while
implementing a JNI interface?
Thanks,
Nisahnt

NishantMungse wrote:
The assumption here is that java code calls a C function from a
shared library in Linux.
How should memory management be done in the native code called
from Java using a JNI interface?
C: Alloc something giving a pointer
C: Return pointer to Java as a long.
C: As needed methods take a long parameter and cast to correct pointer.
C: Provide a destroy() method that takes a long, casts to correct pointer and deallocates correctly.
Java: class keeps long
Java: As needed JNI methods are passed long
Java: Provide a destroy() method which passes long to C destroy() method if long is not zero. After call set long to zero.
Java: Optional: Add a finalizer. It calls destroy()
Last step is optional if your programming environment is strict AND the usage of the class has a restricted scope.
The above assumes that you are going to use the memory in a 'normal' way. For instance there allocations are relatively small, and exist for short amounts of time. If that isn't true then you might need to tune the usage in much the same way that you might if you had a Java class that consumed a large amount of memory.
What role does the Garbage Collector play in handling memory that
was allocated in the native C code?
It doesn't.
At some point it can interfere with the heap though.
If I allocate memory using malloc() in the C program, should I
explicitly free it? Will the GC take care of it?
You must explicitly free it.
Does anyone have an idea of how memory management be done while
implementing a JNI interface?See above.

Similar Messages

  • Use JNI application has memory manager, feasible?

    Hi,
    This is an attempt to circumvent javas poor memory management capabilities. Since java is unable to allocate memory dynamically (*) I'm thinking of writing a native library capable of allocating memory and then allowing java applications to stow away data in this area. The application would be able to access the memory directly through some java.nio.ByteArray-type implementation.
    The java application would be responsible for allocating and deallocating, reading and writing data.
    Is this feasible? Has anyone done this already? I guess a JNI is solution would be pretty straightforward?
    (...this will be my first experience with JNI)
    (*) Xmx option can be used assuming you know beforehand the memory requirements.

    Hi,
    This is feasible since JNative already does this.
    See Pointer and MemoryBlockFactory classes to do this.
    --Marc (http://jnative.sf.net)                                                                                                                                                                                                                                                                                           

  • Logical systems while implementing charm in solution manager

    Hello Everybody,
    I just wanted to know how many logical systems we need while implementing charm in solution manager 7.0. I have 3 clients in development , 3 clients in Quality and 1 client in production.
    Thank you,
    vikram.

    Hi Vikram,
    Yes, i1n ChaRM we always work with logical systems, I mean clients.
    The standard is:
    DEV -> QAS -> PRD
    However, you can also use:
    - Minimum
    DEV -> PRD
    - Target groups
    DEV -> QAS -> PRD
             - > TST
    DEV -> QA1 -> QA2 -> PRD
    DEV -> QA1 -> PR1
             -> QA2 -> PR2
    There are a lot of combination possible.
    BR
    Fernando

  • While Implementing ESOA projects

    Dear Experts,
    I have some questions regarding implementing an ESOA project:
    <u><b>1. Regarding UI Technologies</b></u>
    1. While consulting clients, how can we recommend them which UI technology to use for front end development. say it be Visual composer or Web Dynpro. What are the standards for their selection?
    <u><b>2. Regarding development language</b></u>
    1. what is more efficient language to use? ABAP or Java for development?
    <u><b>3. Regarding Project Evaluation</b></u>
    1. How can we implement and evaluate an ESOA project? Are there some methodology or tools for it?
    Thanks in advance,
    Kind regards,
    sudeep

    What are you talking about?
    ESOA is an Enterprise Service Oriented Architecture specification from SAP.
    ESOA narrow down the gap between IT and business during the IT enablement of business requirements using technologies and frameworks.
    As a consultant the most important objective of ESOA should be to teach your client about defining service interface using SOA principles.
    A Service Interface is an implementation independent definition using common semantics such as XML so that a service provider can implement the service specification according to service contract using their own technology. Since SOA provide business vision without concerned about implementation (using interfaces of services) it can bring the agility and quality
    When you guys talk about JAVA, ABAP, UI etc they are either technologies or frameworks with service enablement, but not really SOA itself.
    Your success of ESOA initiatives are always defining AGILE , SOA principle based services using service interface and definition right governance and management around the services using enterprise vision. Once business start to think about IT enablement in terms of services instead technology program such as JAVA pojo, RFC module, ABAP code, BAPI, EJB etc. business can re-align their dynamic business goals without dealing much with IT programmers or low level system guys. These concepts bring agility to business but still use complicated IT.
    If you start think about SOA services from a tool perspective without putting much attention to the real objective of SOA itself, frankly u r killing the concept and trying make your client feel that it is all about learning some SOA enabled tools. If you follow that approach, either you are not capable to think in terms of an architecture principle or just hanging around IT cuz it pay good also trying fish in the traditional water where you feel that if you learn some tool you automatically became developer, designer, architect or whatever you wanted to be.
    SOA is an Agile Architecture concept based on SOA principles which advice business and IT professionals to think in terms of services so that agile IT enablement of business are made possible. IT is not just about tools or technologies.
    Thanks
    Message was edited by:
            Shaji Nair

  • Dummy Implementation of Interface

    Hi SAP Gurus & Mr Uwe,
    I'm interested with your discussion (Mr Uwe's commented) a while ago regarding dummy implementation of interface on Mar 25, 2008 12:52 PM.
    I saw this CL_EX_CRM_BUS20001_R3A class of mine has the same code as the topic that you commented.
    I would like to know about this dummy implementation of interface. Firstly is what is the use of this interface? I assume that this program is the main BADI so it should have all the parameters required for the next program which is in this case is the interface. Is that right?
    Thank you very much for your insightful explanation.
    With kind regards,
    Michael

    Hi Adrian,
    Did you have any success with your Trading Partner Directory?
    Our project includes ECC, CRM 5.1, SRM6.0 and Portal. We have this CRM scenario where a customer (manager) logs on and approves one of his employees, already self-registered, as a customer Portal user. UME seems to support that scenario, but it can only retrieve company information from a SRM backend system using a custom implementation of the Trading Partner Directory interface. In our case it is a CRM scenario and CRM Business Partners are not replicated on SRM.
    What is that SRM Trading Partner Directory interface and how much effort is involved in this custom implementation?
    Does the portal need to restart for new Companies to be added?
    Is there a better way to update the list of companies in UME from a list of CRM Business Partner?
    Thanks

  • JNI interface - error creating buffer caches 1GB

    Hi,
    I seem to be having a problem creating environments with a buffer cache of larger than 1GB. I get the following error, or similar:
    (BDB v 4.3.29)
    MapViewOfFile: Not enough space
    PANIC: Not enough space
    PANIC: DB_RUNRECOVERY: Fatal error, run database recovery
    (and on BDB v 4.7.25)
    MapViewOfFile: Not enough storage is available to process this command.
    PANIC: Not enough space
    PANIC: DB_RUNRECOVERY: Fatal error, run database recovery
    unable to join the environment
    I definitely have enough storage space available on the hard drive. This occurs whether I set the size of the buffer cache in code, or in the DB_CONFIG file. I have had the problem on both Linux and Windows and with BDB 4.3.29 and 4.7.25. I have also tried splitting the buffer cache into multiple files, this doesn't help, although in some situations I get a floating point error originating from inside the JNI library (I can provide more info on this if necessary).
    Any suggestions? Is there a hard limit of 1GB that I've missed for buffer caches created over the BDB JNI interface? I wrote a quick C program to test this out, and managed to get the buffer cache up to ~2.5GB before I hit similar errors.
    Thanks in advance for any advice.

    Hi,
    Thanks for the reply Sandra. Below is an example that causes this issue for me. As a quick aside, could this be an O/S / architecture limitation? I'm running a 32 bit O/S (XP SP2, Linux), could it be an issue with allocating that much addressable memory to a single process?
    Many thanks
    Code starts:
    package main;
    import java.io.File;
    import java.io.FileNotFoundException;
    import com.sleepycat.db.Database;
    import com.sleepycat.db.DatabaseConfig;
    import com.sleepycat.db.DatabaseException;
    import com.sleepycat.db.DatabaseType;
    import com.sleepycat.db.Environment;
    import com.sleepycat.db.EnvironmentConfig;
    public class TestBDB {
    public static void main(String[] args)
    EnvironmentConfig envConfig = new EnvironmentConfig();
    envConfig.setInitializeCache(true);
    envConfig.setAllowCreate(true);
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setType(DatabaseType.BTREE);
    dbConfig.setAllowCreate(true);
    Database db;
    Environment env;
    try
    env = new Environment(new File("D:\\test"), envConfig);
    db = env.openDatabase(null, "test.db", "test.db", dbConfig);
    if (db != null)
    db.close();
    if (env != null)
    env.close();
    catch(FileNotFoundException e) {
    e.printStackTrace();
    catch (DatabaseException e) {
    e.printStackTrace();
    }

  • Segmentation Fault at JNI Interface

    Hi All,
    We have developed a JNI Interface (Java to C call in Linux environment). This is used to connect to some bea tuxedo service.
    Once started the interface works fine upto one to 2 days. After that we receive a segmentation fault.
    For easier understanding - I am adding one native function implementation here. I am not an expert in JNI.
    One thing I know is that we have to use GetStringUTFChars and ReleaeStringUTFchars in pair. Thats what is already done. Is there anything else that might cause the memory leak that we are experiencing ? I am sorry that the function is a large one.
    thanks in advance
    Ahmed
    JNIEXPORT void JNICALL Java_com_ect_givr_vodafone_kias_CSM30Processor_read
    (JNIEnv *env,jobject csm30Processor,jobject haRequest, jobject haResponse)
         jfieldID fid;
         jstring jstr;
    const char *str;
    jint status=-2;
         haCSM30ReadReq_t csm30ReadReq;
    haCSM30ReadResp_t csm30ReadResp;
         jclass reqcls=(*env)->GetObjectClass(env, haRequest);
         jclass rescls=(*env)->GetObjectClass(env, haResponse);
         fid = (*env)->GetFieldID(env, reqcls, "actionType",
    "Ljava/lang/String;");
    jstr = (*env)->GetObjectField(env, haRequest, fid);
         if(jstr!=NULL)
    str = (*env)->GetStringUTFChars(env, jstr, NULL);
    strcpy(csm30ReadReq.action_type,str);
    else
         strcpy(csm30ReadReq.action_type,"01");
         (*env)->ReleaseStringUTFChars(env, jstr, str);
    fid = (*env)->GetFieldID(env, reqcls, "ndc",
    "Ljava/lang/String;");
    jstr = (*env)->GetObjectField(env, haRequest, fid);
    if(jstr!=NULL)
    str = (*env)->GetStringUTFChars(env, jstr, NULL);
    strcpy(csm30ReadReq.ndc, str);
    (*env)->ReleaseStringUTFChars(env, jstr, str);
    fid = (*env)->GetFieldID(env, reqcls, "msisdn",
    "Ljava/lang/String;");
    jstr = (*env)->GetObjectField(env, haRequest, fid);
    if(jstr!=NULL)
    str = (*env)->GetStringUTFChars(env, jstr, NULL);
         strcpy(csm30ReadReq.msisdn, str);
    (*env)->ReleaseStringUTFChars(env, jstr, str);
    status = pha_csm30_read_request(&csm30ReadReq, &csm30ReadResp);
    if ( status != SUCCESS )
    printf("ERROR CSM30: tuxedo call failed for read request\n");
    fid =(*env)->GetFieldID(env,rescls,"status","I");
    (*env)->SetIntField(env,haResponse,fid,status);
    else
    fid = (*env)->GetFieldID(env, rescls, "actionType",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.action_type);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "returnCode",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.return_code);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "ndc",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.ndc);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "msisdn",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.msisdn);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "FF_Country_Code1",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.csBestFf1.ff_cc);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "FF_Country_Code2",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.csBestFf2.ff_cc);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "FF_NDC1",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.csBestFf1.ff_ndc);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "FF_NDC2",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.csBestFf2.ff_ndc);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "FF_Number1",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.csBestFf1.ff_number);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "FF_Number2",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.csBestFf2.ff_number);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "customerType",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.cust_type);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "tariff",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.tariff);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid = (*env)->GetFieldID(env, rescls, "additionalServices",
    "Ljava/lang/String;");
         jstr = (*env)->NewStringUTF(env, csm30ReadResp.additional_services);
         (*env)->SetObjectField(env, haResponse, fid, jstr);
         fid =(*env)->GetFieldID(env,rescls,"status","I");
    (*env)->SetIntField(env,haResponse,fid,status);
    }

    Hi. This question is more suitable for the DbXml forum:
    Berkeley DB XML
    Ben Schmeckpeper

  • What is difference between 32 bit and 64 bit sql server memory management

    What is difference between 32 bit and 64 bit sql server memory management
    Thanks
    Shashikala

    This is the basic difference...check if helps:
    A 32-bit CPU running 32-bit software (also known as the x86 platform) is so named because it is based on an architecture that can manipulate values that are up to 32 bits in length. This means that a 32-bit memory pointer can store a value between 0 and
    4,294,967,295 to reference a memory address. This equates to a maximum addressable space of 4GB on 32-bit platforms
    On the other hand 64-bit limit of 18,446,744,073,709,551,616, this number is so large that in memory/storage terminology it equates to 16 exabytes. You don’t come across that term very often, so to help understand the scale, here is the value converted to
    more commonly used measurements: 16 exabytes = 16,777,216 petabytes (16 million PB)➤ 17,179,869,184 terabytes (17 billion TB)➤ 17,592,186,044,416 gigabytes (17 trillion GB)➤
    As you can see, it is significantly larger than the 4GB virtual address space usable in 32-bit systems; it’s so large in fact that any hardware capable of using it all is sadly restricted to the realm of science fiction. Because of this, processor manufacturers
    decided to only implement a 44-bit address bus, which provides a virtual address space on 64-bit systems of 16TB. This was regarded as being more than enough address space for the foreseeable future and logically it’s split into an 8TB range for user mode
    and 8TB for kernel mode. Each 64-bit process running on an x64 platform will be able to address up to 8TB of VAS.
    Please click the Mark as answer button and vote as helpful if this reply solves your problem

  • Error code kernel data inpage , memory management , 0xc000021a , 0xc00000e9 on windows 8

    Hi everyone I am sahasvat.I am using Acer aspire 5755. It's specification are Intel i3 3rd gen processor, 2Gb DDR 3 ram and 500 GB hdd.I am running on windows 8 OS. I opened about 4 tabs on google chrome and suddenly a blue screen with sad face displayed
    an error kernel data inpage and it got restarted and after 5 mins I opened google chrome and again blue screen came and displayed an another error memory management and while restarting on bios I pressed f8 and booted to safe mode as normal
    mode didn't open.soon after 20 mins I restarted my lap and I received an error 0xc000021a bios and windows booted.i then pressed power button for a min and switched on my pc but it showed a different error 0xc00000e9. I restarted many times
    either 0xc000021a or 0xc00000e9 used to come not an fixed error. I don't have my cd as it got scratches on CD.  Plzz help me to get out of this problem.
    I can't even access my laptop and I am using my windows phone to post this.

    Hi everyone I am sahasvat.I am using Acer aspire 5755. It's specification are Intel i3 3rd gen processor, 2Gb DDR 3 ram and 500 GB hdd.I am running on windows 8 OS. I opened about 4 tabs on google chrome and suddenly a blue screen with sad face displayed
    an error kernel data inpage and it got restarted and after 5 mins I opened google chrome and again blue screen came and displayed an another error memory management and while restarting on bios I pressed f8 and booted to safe mode as normal
    mode didn't open.soon after 20 mins I restarted my lap and I received an error 0xc000021a bios and windows booted.i then pressed power button for a min and switched on my pc but it showed a different error 0xc00000e9. I restarted many times
    either 0xc000021a or 0xc00000e9 used to come not an fixed error. I don't have my cd as it got scratches on CD.  Plzz help me to get out of this problem.
    I can't even access my laptop and I am using my windows phone to post this.

  • OSX inactive memory management problems

    On my 2010 Macbook Air 11" running OSX 10.8 Mountain Lion, I have run into some major issues with memory management. This problem persists across both my Mac machines and multiple generations of OSX. I have a 2007 2.2 Ghz Core 2 Duo Macbook Pro Running Lion (upgraded from Tiger) with 3 gb 667Mhz DDR2 RAM and my 2010 Air 1.4Ghz Core 2 Duo (Upgraded from Snow Leopard to Mountain Lion) with 2gb 1067mhz DDR3 RAM. On both machines, for some time now, during normal usage; especially web browsing using Chrome and Safari (respectively); the inactive RAM on both machines will grow to consume around 30% of all RAM and force time consuming page outs to the mass storage drives on both machines. The Pro has a slower hard drive and the problem is the worst here, the air has a much faster SSD. I have found myself constantly having a window of Activity Monitor up on at least one of my desktops watching my RAM usage, using terminal to purge ram upwards of 10 times an hour to prevent costly page outs, especially on the Pro. I know Apple claims that inactive RAM is essentially free RAM that is temporarily storing recently used information for ease of access later and that it's supposed to be released as free memory when needed, but this obviously is not happening. Right now on my air my swap file is over 650Mb and I've seen it top 2Gb before. The air is exponentially better than the Pro due to the faster SSD, but I do notice substantial UI lag and a massive drop in fluidity as soon as my meager 2Gb is full and I start paging. The Pro is another story entirely, the entire system will essentially become unusable, having to wait several seconds for mouse clicks to even register. That's why I upgraded the stock 2Gb of RAM it comes with to 3Gb hoping that a 150% increase in RAM would help, but it just prolonged the inevitable. I still end up paging out just as bad across both systems if un checked. Even when I keep a close eye on memory usage and purge often, I still end up paging out because I'm not vigilant enough.
    I have to limit my browsing to less than 5 tabs and keep my number of open programs less than 2 on both machines. My active and wired memory rarely seem to top 70%, meaning the rest gets taken by inactive, which isn't functioning as Apple claims. Even if my conclusions aobut what is happening under the hood are incorrect, something is going terribly wrong. I can't upgrade the RAM on my Air at all, and the RAM on my Pro is capped at 4Gb. I'm holding on upgrading because I don't think the excess hardware will solve this software memory problem. Whatever is happening is causing a serious drop in performance for me (yes I do know I have underpowered machines), but there has to be something I can do to speed performance. I've read about disabling the dynamic page file entirely, which just seems to crash the system when free memory is gone, and I've read about programs that claim to free memory. Those programs seem to work by taking a high priority in the process heigharchy of the OS and then proceeding to eat up large portions of RAM and releasing them as needed in an attempt to replicate the true intentions of inactive RAM, but I've heard of problems with this method as well. Does anyone have a viable solution? Monitoring my RAM usage myself and ensuring I don't end up paging out is costly, time consuming, annoying, and inefficient since I fail to catch the problem before I page if I get particularly busy. There is no other OS I've ever been acquainted with that has this problem, not any flavor of Linux, not even the dreaded windows. I seriously hope Apple can do something to manage this runaway memory problem. I'd like to be able to open more than 3 windows in Safari. I've had to purge 3 seperate times while writing this on my Air, and I now have 678 inactive memory, 741 inactive, 582 wired, and less than 14Mb free out of 2Gb with a growing swap at 680Mb. Each purge becomes less and less effective and the last one I did freed up only about 100Mb and it got eaten up again by inactive in less than 10 seconds. On my Air, the memory hog is Safari right now at 700Mb between the web content and flash player with only Facebook, youtube, and this Apple Supprt tab open. I have NO other applications running in the fore or background other than Activity Monitor and Terminal. On my Pro the memory hog is always kernel task, I use Chrome and Safari both. While the memory used by the browser does not usually take up the most substantial portion of the total used RAM out of any process, the more tabs I open, the more RAM I use. The browser is usually the second heaviest RAM hog to Kernel Task. So it seems that across the two machines there are two lsightly different manifestations of the same problem with the same results: massive performance drops and extremely annoying and costly page outs no matter the reason. I just want this problem to go away. I've used underpowered windows laptops that can open a dozen tabs in a heavier browser like IE or Firefox while using other programs like Word or Excel and more with no memory lag issues. There's no way in **** I could manage to open that many pages in a browser while using Pages and/or Numbers on either of my machines and expect reliable (swap free performance). This is just kind of sad in my opinion. Does anyone have a way to get my OSX machine running smooth so that I can remove the one thing that windows and Linux fan boys get the right to laugh at my Macs for?

    Hi Zephryl,
    I was actually able to get an initial response from Sun on this a few months ago. However, the Sun Swing team has not followed up on a resolution for this pervasive problem, even though they noticed the same problem when running a test applet I had created for them. Apparently, I.E. is not releasing memory from the heap.
    Below is a quote from a Sun rep. on this in an e-mail sent to me on Dec 4, 2002:
    "I suspected the leak is in the native code because the # of handles and GDI objects keep increasing but no obvious Java objects are left behind in the Java heap during page switch."
    So, until Sun and/or Microsoft work out a solution to this, anyone who uses I.E. 6 and applets for their UI seems to be in a lot of trouble.
    As a note, trying to invoke the Garbage Collector does not do anything, but generally a very small amount of memory will be released (like maybe 5-10% of the memory allocated for the applet).
    Cheers!
    Avi Gray
    Global Computer Enterprises

  • Java Memory Management/Out of Memory

    Hi Guys,
    I have a few questions about java memory management
    Because i keep encounter a lot of out of memory error which i think java does not handle Vector/ArrayList re initialisation automatically
    Asumme i have 2 million record in database and , i will process every 80000 and store it in Vector
    while(true)
    list = new Vector();
    list = GetResultFromDatabase() // Process Every 80000
    if list.size() > 0 =======> My VEctor list contain 80000
    //loop the 800000
    //Process Some logic and data
    list.clear();
    list = null;
    If u See , i need to call list.clear and list = Null every process so it wont cause me out of memory
    Before i put that 2 lines , i always hit out of memory Exception.
    Seems like garbage collector cannot claim memory if i dont declare
    Is Memory Occupied by VEctor cannot be recoverable if we dont explitcitynya clear it and set it to NULL??
    Because in term of logic wise it wont cause a problem if i just
    do in this statement after it process like below
    list = new Vector() which will reinstatiate the object.
    Thanks.

    Damm i should hacve read your post again
    Look here:
    while(true)
    list = new Vector();What uer doing is craeting a new vector object everytime the while does an ityteration so when your while loop does 40000 loops there will be 40000 new objects in jou memory
    i sugest moving the decleration outside the while loop:
      list = new Vector();
    while(true)
    ///rest of loop
    } This could also be a problem
    hope it help :-)
    werns

  • Oracle 9i Automatic PGA Memory Management

    Hello,
    my team and me, we are facing difficulties to change the size of the PGA used by our server processes for HASH JOIN, SORT... operators,
    here you can see the results of "select * from v$pgastat":
    [pgastat dynamic view results|http://pastebin.com/m210314dc]
    We have been increasing consecutively our pga_aggregate_target parameter from 1.7 Gb initially to 4Gb then at the end 6Gb, the value of "Global memory bound" and " aggregate pga auto target" on the link above are still equal to 0.
    I have been reading threads on the forum and documentation see below, I understand how the global memory manager (CKPT) computest the sql memory target and then the global memory bound, as far as I understand I can only "play" on the pga_aggregate_target value in order to increase the size of our PGAs (I exclude to play with hidden parameters).
    - Joze Senegacnik: Advanced Management of working areas in Oracle 9i/10g : http://tonguc.yilmaz.googlepages.com/JozeSenegacnik-PGAMemoryManagementvO.zip
    - Dageville Benoit and Zait Mohamed: SQL memory management in oracle 9i
    Here different information that could be usefull:
    OS: solaris 10 (db running in a non global zone)
    Arch: 64-bit sparcv9 kernel modules
    Physical memory: 32 Gb (being shared between all non global zones)
    Oracle version: 9.2.0.5 32bits
    Values of init parameters and hidden parameters that could be relevant:
    [init parameters|http://pastebin.com/m40340cf4]
    [hidden parameters|http://pastebin.com/m50d74c53]
    Maybe useful queries:
    over work areas views, I use the following script:
    [wa_analysis.sql|http://pastebin.com/d606ebd9b]
    and the result of it:
    [result of script wa_analysis.sql|http://pastebin.com/m5f49a2e5]

    Joze Senegacnik wrote:
    - either your sessions are using a lot of memory for storing variables like pl/sql arrays which is subtracted from automatic management: PGA_AGGREGATE_TARGET - (aggregated persistent area + a part of the run time area of all server processes)
    - you are hitting a bug
    - or maybe something elseI am really happy you come to this conclusion too, they are the same we made with my team and we have submitting to Oracle support via metalink SR 3-1216060641, we were asking if we hit the following bug (in note 1) or we leak about pl/sql or java... or else indeed,
    note 1: PGA_AGGREGATE_TARGET Assigned Memory Is Left Unconsumed When Set High [ID 844542.1]
    Joze Senegacnik wrote:
    I would like to know:
    1.) what were the values for global memory bound and autotarget immediately (or in short time) after the database restart or when you have increased them Just after the restart of the database and just after the change of P_A_T, we query v$pgastat immediately after and the value of global memory bound and auto target were equal to 0 byte,
    2.) If you are able to change value of PGA_AGGREGATE_TARGET (P_A_T) to 10GB what happens with global memory bound and auto traget. They should be positive at least for a short time. As this is a dynamic parameter you can change it for a short time, run queries and set it back.We plan to do this tonight, we have an "heavy" ITIL change management procedures that allow us to make changes approved by change manager and only during night maintenance window on production system, I come back to you tomorrow. But we have been increasing from 1,7Gb to 4Gb to 6Gb, each time I have been querying v$sgastat in the next 2 mins and global memory bound and auto target were equal to 0 byte.
    3.) Have you checked on the OS level how much memory are using server processes - do these numbers come along with what Oracle says. Not during problematic activities, meaning active work areas performing HASH-JOIN, SORT... operators,
    unfortunately it is a production system, even if he performs poorly, we are not allowed to try or retry the poor queries, but if it comes again I'll do it,
    during low activities, here the results paste with the scripts I used:
    [pga processes info in oracle|http://pastebin.com/f2e540062]
    I spooled the result rows of this previous script in /var/tmp/pga_processes.log then I loop over all processes pid and display pmap output anon info like this:
    h5. cat /var/tmp/pga_processes.log | awk -F' ' '{print $5}' | xargs -n 1 -i pmap -x {}| grep -v 'Addres' |egrep 'Kb' 2>&1 > /var/tmp/pga_processes_os.log
    then I merge line by line the two files with unix paste command, here the results:
    [os and oracle pga informations|http://pastebin.com/f4135c8a6]
    4.) How many server processes are running on you system in average/max and are you using just dedicated processes or also shared?in average 250, we are only using dedicated processes,
    5.) At time of low activity is the global memory bound still 0 or becomes > 0. I have been querying every 15 min during more than 24 hours low activities, it still stay to 0,
    5.) Are you experiencing paging/swapping on OS level?No, here orca figures for details:
    [free memory|http://img509.imageshack.us/img509/5897/ohuron1asd2gauge1024xfr.png]
    swap
    [pagein pageout|http://img121.imageshack.us/img121/6946/ohuron1asd2gaugepginper.png]
    [memory usage|http://img19.imageshack.us/img19/2213/ohuron1asd2gaugeppkerne.png]
    6.) Please post the result of: select * from X$QESMMSGA ;during low activities, [results X$QESMMSGA|http://pastebin.com/f61df7093]
    While you will be answering to my questions I'll try to figure out what we can do to properly diagnose the problem. As you are on 9i it is a little bit harder.I am really kind of your help, as we say in my country, "if you need tow arms one day to carry something, call me."
    --Jeremy Baumont                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Differences in JVM memory management in 1.4.2 and 1.5?

    Hi all,
    We have developed some code calling a third party dll through JNI. The code runs fine on jre 1.4.2. When we test in on jre 1.5, the dll is giving us a heap memory exhausted message. We have set -Xmx to 1024m due to performance issue. If we lower -Xmx from 1024m to 912m, then the program runs fine. So I have question if memory is being handled differently in 1.4.2 and 1.5?
    Envirnoment: Windows XP, JRE 1.4.2 and 1.5, 1GB memory
    Thanks all!

    Hi,
    I keep some rules while developing JNI code:
    - reduce to minimum use of Local Heap, try to use Global or Virtual memory,
    - reduce to minimum a number of local/gobal references used, make shallow copy of the same reference like it is done in Windows COM,
    - reduce to minimum a number of stack variables,
    - be sure that JNI code has no memory leaks.
    To solve these problems I have developed for MS Visual Studio tools
    http://www.simtel.net//product.php%5bid%5d93174%5bSiteID%5dsimtel.net
    http://www.simtel.net/product.php[id]94368[sekid]0[SiteID]simtel.net
    The tools solve these problems and are used by other people in my company (for developing JNI code). They do not know anything about these issues.

  • JS memory management?

       I've been having a lot of memory errors crashing illustrator lately, I'm trying to rule out scripts as the reason.  Are there any memory management techniques I should be using while scripting for AI?  All the crashes are "Memory could not be written" errors.

    No takers?  I noticed in the scripting guide for CS5 it says this:
    ... A single global, persistent, ExtendScript engine inside Illustrator handles all BridgeTalk communications. The net effect is that the state of the ExtendScript engine is cumulative to all scripts that ran previously...
    This makes me believe that the variables used in a script are not destroyed after a script finishes running.  The scripts I'm writing are extensive, with many, many variables being created.  I'm wondering if I'm running out of memory after running the scripts so many times.  Do I need to be destroying my own variables as part of my scripts?  If so, how do I do that?

  • MAC OS X Lion performance problem - broken memory management

    Starting with OS X 10.5 there are evident memory management problems in MAC OS X. The web was already then cluttered with complaints about system slowing down dramatically after some time. Back then i had slower machine, Mac Mini with 1GB RAM, so i (wrongly) concluded that it was due to inferior hardware.
    Now i have 2010 MBP, core i7, 8 GB RAM, dual GPU.
    Mac os X Snow Leopard was pain, but after migrating to OS X Lion, working some serious stuff on MAC started to be a nightmare.
    I finally managed to reproduce the problematic scenario, so i run the test and recorded the screen, into video.
    http://www.youtube.com/watch?v=u5wZwZh61_4
    I run the tar+bzip command, which is basic unix stuff, on the large amount of picture files, in my Pictures/ folder. Just before start, i run the "purge" command, to delete inactive/cached program data.
    You can see on the video that free memory starts to drop very fast, and inactive is constantly rising. If you take a look at "bsdtar" command, it takes only a fragment of RAM, so the problem is not in this process. You cannot say that it is a program memory leak, because then the problem would not be in inactive ram, rather in active/wired.
    When the free memory dropped below 100mb, i started some apps, like Safari, iPhoto and MS Word, and you can see in the video, that it takes even minutes to start an app, when normally (when there is free RAM), it would take some 3-5 secs to load.
    I run the same scenario and the same commands on my Linux Centos 6 box, no problem there ! Memory usage is some 10-20mb, no problems with cache/buffer.
    The memory management must be very broken in Mac OS X !

    Broken?  That's a bit harsh.
    Immature?  That's perhaps a better explanation.
    This paper describes Priority Paging as implemented in Solaris 2.7 back in 1998, and that's essentially what Mac OS X is in need of today:
    The problem is that when pages are needed, no differentiation is made between system file cache pages and application pages, and worse, the file cache can actually steal pages needed by applications.
    Finally when Dynamic Pager starts up and needs to start swapping things out, it's fairly heavy weight in operation, and causes the UI not responding cursor (aka the spinning beach ball) to appear.

Maybe you are looking for

  • Unclear about requirements/information for Edge vs Contract plans.

    I am currently on a 8GB/70 Shared data plan with a corporate discount.  I have 4 smart phones and 2 iPads.  My total bill is $241.60 + Taxes.  Our contract on all 4 phones is now up as of 2/1/15.  I have been asking questions about switching to the e

  • How to set the control-on hierarchical tree nodes

    Hi, I have created form in which at the left it has hierarchical tree structure(BOM) and towards the right it brings up the query results for selected node. Now, I have a button upon clicking which I navigate to the root node by issuing "Ftree.set_Tr

  • Database Trigger on Oracle 8i

    I am trying to get this trigger to work in 8i and I get "subquery not allowed here" as an error. Is there a way to use subqueries or is another method possible? Thanks so much for your help! CREATE OR REPLACE TRIGGER xx_realbegtime BEFORE INSERT OR U

  • Flash player not recognized

    I am running Windows 8.1 64 bit.  Whenever I try to view something that requires flash player I get a message that Flash player is not installed, or it needs to be updated. I've explored the flash player help site and tried everything there.  When I

  • My iCloud account wont sign in on my computer!

    I restored my hard drive and for some reason it wont let me sign back into my iCloud account through system preferences. I've tried resetting my password and a few other things, but it still wont let me. It wont even let me sign out of my account! Pl