Custom memory pool.

Hi!
I have been studying different ways to implement object cache for server application(s). At the server there are XML files which have to be parsed and validated before delivering to clients. Clients are also sending XML data back to be validated and stored by the server. It would be nice to have object cache between servlets and IO to make server run faster. The ultimate requirement for cache is: There have to be way to set upper limit for caches memory footprint to avoid OutOfMemory.
I found couple of third parties object caches like Java Caching System (JCS), OSCache, Commons Collections, JCache API but none is supporting cache policy to fulfil my requirement. Am I right? Is there any others? (Open Source)
I started also desining my own implementation of object cache but the problem is: How to calculate object size in bytes.
I tried to solve problem by creating interface Cacheable that contains method sizeOf(). It is quite easy to implement and calculate approx size of (simple data) object except String. I wrote my on custom String class to get size. I also wrote some Cacheable implementations of collection classes too. But next problem was that (object) cache become too specific.
Okey, now JMX questions : )
1. Question is: Is it possible to use JMX to create totally new memory pools within same VM for object cache. Why? It would be easy to examine memory usage of cache by examining memory usage of those pools.
2. Is there way to set a classloader to load certain classes to those memory pools.
3. Is it possible to set a "rule" that instances of those classes are placed also into new pools.
4. Does JMX inspection have some severe performance drawbacks?
Plan B
I have also considered idea of running object cache as independent service in its own VM. And connecting to it by RMI. Any comments? Performance issues? Have anybody done this?
Thanks!

I do not think it is possible for user code to create a new memory pool in the sense of the ones that show up in JConsole's Memory tab ("PS Eden Space", "PS Perm Gen", and so on.)
I would in any case advise against getting into the details of object sizes. The question is very difficult - for example, is the size of an object the total size of all objects reachable from it? If so then if x and y are two objects that have part of their object graph in common, adding the sizes you compute for x and y will produce a size that is too big. If you want to get involved in this anyway, a good starting point is <http://www.javaworld.com/javaworld/javaqa/2003-12/02-qa-1226-sizeof.html>.
You can in fact get a number representing the size of a Java object by writing a premain method and then using Instrumentation.getObjectSize. See java.lang.instrument. But this size does not include objects referenced from the given object, so it does not really tell you how much memory the object is taking up. For example, all String objects will show the same size, because the char[] containing the actual contents of the String is another object that is referenced by the String.
The usual way to handle object caching is with SoftReference, see java.lang.ref. Admittedly, this does not give you an easy way to balance the sizes of different pools.

Similar Messages

  • Save a variant in a custom module-pool.

    Hi all,
    i hope there is someone that can help me.
    My problem is: i've to save a variant in a module-pool custom SAPMZ...ecc.
    Is there a function module or a routine or some specific ABAP istruction to save a variant?
    I ask this because in my custom module-pool i've insert input field in main dynpro.
    Thanks a lot,
    regards,
    Alex.

    Please use below code it works for me:
    What I did was copy the function group SVAR.  When it asked what function module to copy just select
    'RS_VARIANT_SAVE_FROM_SELSCREEN' and renamed it to 'ZS_VARIANT_SAVE_FROM_SELSCR'.
    DATA: lv_screen LIKE sy-dynnr.
      CLEAR: t_rkey, t_screen.
      REFRESH: t_rkey,  t_screen.
      t_rkey-report = sy-repid.
      APPEND t_rkey.
      t_screen-program   = sy-repid.
      t_screen-dynnr     = '0101'.
      t_screen-type      = 4.
      APPEND t_screen.
      lv_screen = '0101'.
      EXPORT lv_screen TO MEMORY ID 'MZ_COMISSION_REPORT_F02_SCREEN'.
      CALL FUNCTION 'ZS_VARIANT_SAVE_FROM_SELSCR'
        EXPORTING
          curr_report          = sy-repid
          vari_report          = sy-repid
        IMPORTING
          variant              = w_variant
        TABLES
           p_screens           = t_screen
         p_sscr               = t_selctab
         p_vari               = t_vari
        EXCEPTIONS
          illegal_variant_name = 1
          not_authorized       = 2
          no_report            = 3
          report_not_existent  = 4
          report_not_supplied  = 5
          OTHERS               = 6.
      t_rkey-variant = w_variant.
      MODIFY t_rkey INDEX 1.
      CALL FUNCTION 'RS_RWSET_SAVE_VARIANT'
        EXPORTING
          rkey    = t_rkey
        TABLES
          selctab = t_selctab.
    Then in program LZSVARF07 function save_as_variant find where it's transfering the screen.
      READ TABLE variscreens WITH KEY dynnr = sy-dynnr.
      IF sy-subrc NE 0.
        IMPORT lv_screen FROM MEMORY ID 'MZ_COMISSION_REPORT_F02_SCREEN'.
        IF lv_screen IS INITIAL.
          variscreens-dynnr = sy-dynnr.
        ENDIF.
      ENDIF.
      PERFORM fill_varidyn TABLES p_dynsfields
                           USING  $rkey space. "Kein import von DYNSFIELDS
    Good luck!
    Edited by: Alex Nguyen on May 2, 2009 1:36 AM
    Edited by: Alex Nguyen on May 5, 2009 5:26 PM

  • Triggering Workflow from Custom Module pool

    Hi,
    I am trying to trigger my workflow from my custom module pool using the function module "SAP_WAPI_START_WORKFLOW". I am passing the following parameters for the above function module
    TASK, LANGUAGE, DO_COMMIT, USER and INPUT_CONTAINER
    but, it is returning the following message
    "You are not one of the possible agents of task 'WS90100020'"
    Please suggest a solution for this problem?
    Regards
    Sujith P. Soman

    Hi,
    A better way would be to trigger your WF using an event and calling SAP_WAPI_CREATE_EVENT. But if you want to start it directly then if you are calling this FM in dialog you need to be a possible agent. The easiest is if you jsut make it a general task so anyone can start it.
    In PFTC, open your WF goto Additional Data -> Agent assignment -> Maintain. Click on 'Attribnutes' and select 'General Task'.
    Also run SWU_OBUF afterwards to synch all buffers before testing your FM again.
    Cheers,
    Mike

  • Custom module pool + Amount field decimals display same as standard screen display

    Hi All,
    Requirement: A custom module program screen field has to be designed which displays decimal values of amount fields same as amount fields in standard screen.
    Standard screen behavior: If the standard screen fields are observed, they refer to data elements WRBTR or AZSOL_F05A (transactions FB50/FB03/FB01). However, number of decimal places that are visible on screen are dependent on the currency that is provided.
    Both the data elements have 2 decimal places.
    For currency USD two decimal places are displayed - in TCURX - decimal places are two.
    For currency JPY or CLP - zero decimal places are displayed  - in TCURX - decimal places are zero.
    i.e., even though the screen field refers to data element or domain that has the characteristic to show 2 decimal places, based on currency, decimal places are adjusted.
    I would like to know how this is happening on standard screen fields.
    Solution Required for: How to make the custom screen amounts to display same number of decimal places as standard screen amount fields.
    P.S: Before posting the query here, research has been done in SDN and other places. It has been identified that quantity fields adjustments are discussed. However for amount field even though discussed earlier, did not reach a conclusion.
    I would like to get a solution for this one.
    Thanks in advance.
    Goutham.

    Thank you all for taking time to take a look at this query.
    This issue has been resolved.
    Resolution: If the standard transactions (FI transactions in specific) are observed, whenever there is a field that displays amount value, there will be a corresponding field (may not be beside the amount field, somewhere on the screen or in the same sequence of screens) where the currency key value would be entered.
    For instance, if you look at FB50 - there is field on top for the user to input currency key value (like USD or CLP or INR).
    When any amount field is declared - this currency key field is provided as the reference field in the screen attributes of the amount field.
    In short, in the custom module pool program, provide a field that holds currency key value and use this field as reference field for the amount fields.
    Do repond to this thread if the resolution is not clear.
    Thank you all once again.
    Goutham.

  • Custom Module Pool...

    Hello SDN ABAP Community,
    I researched this question on the web and in SDN before posting this because I would like an up-to-date understanding of best way to do this.
    I have a need to write a custom module pool.  It has been a while since I have been to class.  I need to get figured out how my naming conventions will work for all the pieces of the module pool (SE51, SE41, pieces of the SE38 module pool).
    I seem to remember the teacher saying that the way that SAP allows for customer created module pools was to set the 5th character of the name to 'Z'.  eg- sap would use SAPMPetc.  customer would use SAPMZetc.
    From my searching of web I found following naming standards...
    Module pool                             - SAPDY* SAPDZ*
    Module pool for dialog               - DY* DZ*
    INCLUDES                              - SAPMY* SAPMZ*
    Module pool for screens            - MY* MZ*
    INCLUDES                              - MP9*
    Module pool for info types         - MP9*
    INCLUDES                              - SAPFY* SAPFZ*
    Module pool for subroutines      - FY* FZ*
    INCLUDES                              - SAPUY* SAPUZ*
    Module pool for update program - UY* UZ*
    INCLUDES
    From searching SDN I found following link for ABAP objects, but I am needing for module pool.
    http://help.sap.com/saphelp_nw04/helpdata/en/92/c2b084bc1d11d2958700a0c94260a5/frameset.htm 
    So my question... is there any SAP resource that I can look at to see SAP naming conventions for customer created module pool with SE41, SE51 and SE38?
    Thank you,
    Dean Atteberry.

    Hi Dean, here you can take a look at SAP´s official customer name ranges for all objects, including Module Pool: http://help.sap.com/saphelp_nw04/helpdata/EN/2a/6b0b1f547a11d189600000e829fbbd/frameset.htm
    Best regards,
    Federico Alvarez

  • Command line interface to "code cache" memory pool utilization

    I need to monitor the usage of the "code cache" memory pool through a command-line interface, but it doesn't seem to me that the jstat tool is able to give me any information about this particular memory pool. Are there any other tools that is able to give me the details I need? I'm using both JDK 5 and 6.
    Edited by: normann1974 on Jul 10, 2008 9:40 AM

    Typically, this is a class path Problem when the JVM is unable to locate a
    class. Are you sure that the class listed as missing below is included in
    your class path?
    Michael Girdley, BEA Systems Inc
    Learning WebLogic? Buy the book.
    http://www.learnweblogic.com/
    "Pascal Guillot" <[email protected]> wrote in message
    news:3a5df1ee$[email protected]..
    >
    I seem to be running into dificulties when attempting to use theweblogic.Admin class for any commands from the command line
    I am running from a Solaris 5.7 box, and java version 1.1.6, and weblogic6.0 server is running in the background
    Anytime I attempt to run the class:
    java weblogic.Admin <commandofsort> (followed by any neccessary args) Iget the following error msg:
    >
    java.lang.NoClassDefFoundError: javax/management/AttributeList
    at weblogic.management.commandline.CommandLineArgs.<init>(CompiledCode)
    at weblogic.Admin.main(Compiled Code)
    (I can successfuly invoke most of the utililities in the utils classhowever)
    >
    any ideas?
    Pascal

  • Memory Pool Error/s with VxWorks

    Hi,
    I am running Berkeley DB under vxWorks and am encountering memory pool errors. The version we are using is 4.5.20, and we are building a "Concurrent Data Store Application" (small footprint, MIPS64gnu).
    The environment flags are set as follows:
    (DB_INIT_CDB | DB_INIT_MPOOL | DB_CREATE | DB_SYSTEM_MEM)
    The cache size is set to 1MB.
    I believe I have found the offending routine. It is __db_tmp_open in db-4.5.20\env\env_open.c.
    Initially I was receiving the following error:
    db_starchoice: unable to create temporary backing file
    db_starchoice: temporary open: /ata00/oracle/temp/BDB0-*/*: S_dosFsLib_ILLEGAL_N
    AME
    So, I modified the above mentioned routine to generate a legal file name. At which point the file name became:
    /ata00/oracle/temp/BDB87bc4940
    87bc4940 is the PID in hex.
    I am no longer told that the file name is illegal, however, an exception is thrown with the following trace:
    800a5bdc vxTaskEntry +c  : excTask (0, 0, 0, 0)
    8014dca8 excTask +b8 : sigPendKill (eeeeeeee, eeeeeeee, eeeeeeee, eeeeeee
    e)
    80159c28 sigPendKill +118: 801592b8 (eeeeeeee, 8014dcb0, 0, 0)
    80159300 sigPendDestroy +248: sigismember (0, 0, 0, 7400ff01)
    Do I have some configuration incorrect? Is there a known problem with this code, for which I am unable to find reference to?
    Thx,
    Coralie

    I have more information about this problem.
    If I "disable" the routine __os_zerofill() in os_fzero.c, by having it always return (0), I no longer get an exception and my application appears to run smoothly. However, I have not determined what in this routine leads to the exception. And, I have no idea what the short and long term consequences of "disabling" this routine will be....
    -Coralie

  • Adjust memory pool after application launched

    Hi, all
    Is it possible to change memory pool after application launched? For example, in command line 'javaw -Xms32m -Xmx64m' and I want to double it after launched. If it is possible, how can I do that?
    Thanks,
    Vincent Chen

    You cannot change the limits once the JVM is running.
    Maybe you can use Runtime.exec() to start a new JVM with higher limits?

  • Memory pool Code Cache increasing over time

    Hi,
    We are using JConsole to monitor some of our servers which are running JCAPS. We have a couple of JCAPS applications deployed on these servers. We are using JConsole to monitor this server and we can see that the Memory pool Code Cache seems to be increasing over time. It is around 21M at the moment and has gone up from 18M 3 days back. Is this accepted behavior? Should it not be a varying graph, going down coming back up again?
    Any help in this direction is much appreciated.
    Cheers,
    Suchitra

    This might be due to this bug raised for JDBC Client/Server connection
    Bug 12969330 : MEMORY LEAK IN JDBC CS FOR CALLABLE/PREP STATEMENT W/ NUMPARM % 4 != 0
    There is a leak in JDBC driver which seems to affect only C/S; it does not seem to affect direct or batch. ** This bug has been there since 11.2.1.6.0.
    Here are few conditions which are needed for this bug to occur:
    1. Application must be using a Client/server connection
    2. Applications repeatedly does the following:
    1. Create a PreparedStatement or CallableStatement
    2. set or register IN, OUT or IN OUT parameters
    3. Number of parameters is not an integral multiple of 4. It is the total number of parameters which matter; parameter type does not matter. JDBC driver leaks memory if the number of parameters in a PreparedStatement/CallableStatement are not an integral multiple of 4.
    3. On a close 1-3 parameters can be leaked.
    If your application deals with above scenario then there is a possible chance of the bug being hit. An example of a scenario :-
    The below PreparedStatement has 1 parameter (so it's not an integral multiple of 4):
    preparedStatement = connection.prepareStatement("SELECT col1 FROM Tab1 WHERE col2 = ? "); <===== Possible memory leak here
    To workaround the bug, you can add 3 dummy parameters -- SELECT col1 FROM Tab1WHERE col2 = ? and 1=? and 1=? and 1=? and set parameters 2,3 and 4 to 1.
    preparedStatement = connection.prepareStatement("SELECT col1 FROM Tab1WHERE col2 = ? and 1=? and 1=? and 1=? ");
    I've seen this bug a couple of times now. I don't think there is a release yet which includes a fix.

  • AME CS4-Memory Pool settings?

    I'm familiar with the memory settings in After Effects.  However, with my recent upgrade from 8GB to 16GB of memory, I was most excited to see an increase in AME speed.  So far, I have seen no change.  I found references to the "Adobe Memory Pool" in several places, but I haven't found a way to allocate more memory to AME.  I'm currently rendering a file in AME that I rendered back when I had 8GB of memory.  It's taking the exact same amount of time.  Memory usage during encode (with no other programs running) shown here:
    Is there a way I can speed up AME rendering?  (An upgrade to CS6 is forthcoming.  But in the meantime . . . )

    Adobe Media Encoder CS4 is a 32-bit application and is thus limited in the amount of RAM that it can use. Installing that additional RAM does no good for Adobe Media Encoder CS4.
    Since you have AME CS6 coming, you'll be happy to know that the CS6 Adobe video applications are 64-bit applications and can make good use of all of your RAM. Plus, there are a lot of other performance improvements.

  • Oracle oas 10.1.3 oc4j java memory pools info...?

    Hello!
    I need to find info about java memory in JVM. What is :
    PS Eden Space
    PS Old Gen
    PS Perm Gen
    PS Survivor Space
    PS MarkSweep
    PS Scavenge
    regards - Marcin

    user8672998 wrote:
    Hello!
    I need to find info about java memory in JVM. What is :
    PS Eden Space
    PS Old Gen
    PS Perm Gen
    PS Survivor Space
    PS MarkSweep
    PS Scavenge
    regards - MarcinHi Marcin,
    To monitor the java memory and to find info on the memory pools & GC parameters, you must first verify that you are running OC4J on JDK release 5.0, and than you must set the jmxremote property for the OC4J instance.
    Using Application Server Control to Set the jmxremote System Property
    To set the enable monitoring of JVM J2SE 5.0 metrics from Application Server Control:
    1. Navigate to the OC4J Home page for the OC4J instance.
    2. Click Administration to display the OC4J Administration page, which contains a table listing the various administration tasks you can perform for this OC4J instance.
    3. If necessary, expand the Services section of the table by clicking the expand icon or by clicking Expand All.
    4. Click the task icon in the Server Properties row of the table to display the OC4J Server Properties page.
    5. Scroll down to the Command Line Options section of the page and select Enable J2SE 5.0 Platform MBeans.
    6. Click Apply to apply the changes.
    7. Navigate to the Cluster Topology page, select the OC4J instance, and then click Restart.
    Manually Setting the jmxremote System Property
    You can also enable monitoring of JVM J2SE 5.0 metrics manually, by including the following string as an OC4J runtime startup option:
    com.sun.management.jmxremote
    Refer the section "Setting System Properties at Startup" in the Oracle Containers for J2EE Configuration and Administration Guide for detailed instructions on how to specify OC4J runtime startup options.
    Specifically, if you are running OC4J in a standalone environment, you must include the following argument to the OC4J java command:
    java -Dcom.sun.management.jmxremote -jar oc4j.jar
    Or, if you are running OC4J in a Oracle Application Server managed environment, you must include the following argument in the start-parameters java-options element in the opmn.xml file:
    <ias-component id="OC4J">
    <process-type id="home" module-id="OC4J" status="enabled">
    <module-data>
    <category id="start-parameters">
    <data id="java-options" value="-Dcom.sun.management.jmxremote"/>
    </category>
    </module-data>
    </process-type>
    </ias-component>
    Regards,
    ~Pointer

  • Premiere Pro, After Effects CS5 & the shared memory pool

    This feature works quite nicely under Win 7 x64. I'm thinking of adding more RAM and going up to 12 GB. However, I noticed that the CS5 shared memory pool is limited to 75% of the installed physical RAM. Although that makes sense if you have  a computer with the minimum system requirements of 4 GB (because Windows itself will use just under 1GB +/-), it makes less sense at 12 GB, where 9 GB is all you can use for the CS5 pool.
    Is this the way it works or is there some way that I can be "greedy" and go above the 75% number for higher amounts of physical RAM? It helps to have as much physical RAM as possible for high resolution AE previews, etc.

    Dennis,
    I noticed that there is a file memorybalancercs5.xml that seems to be used by the various CS5 programs to share the memory pool. I'm not about to play with it, but is that what controls the maximum CS5 usage? Or is it just a common location for all the 64 bit components to keep track of the RAM settings?
    Jay

  • Java 5 management API : memory pools

    Hie,
    I have big issues when trying to find out the actual cycle of life of an object in memory pools. Does anybody have documentation about it ?
    What I kinda understood is :
    1. instantiation of a class : the object goes directly in the Eden Space mem pool
    2. a first run of gc processes this object (this first run of gc() is quite immediate after instanciation) :
    * object is still visible : gc() puts it in the Tenured Gen pool (? or in survivor space???)
    * object is not : there it's quite obscure, gc() randomly collects it...
    What I want to measure is the actual peak of memory heap (that is objects that are still visible and non-collectable).
    So far, i uses getPeakUsage() of the tenured gen pool, which seems to be quite correct...
    so here are my questions :
    * how often do gc() run on each memory pool ?
    * how do gc decide whether an object goes in 'survivor space' or in 'tenured gen'
    Thanks !

    1) There are two types of collecion:
    minor (newgen only)
    major (full)
    minor collection are rather frequently and fast, major are time consuming and rare. GC tries to adaptively set size of newgen to optimize overhead.
    use -XX:+PrintGCDetails switch
    2) This mostly based on object age (how much minor collection it has before, after number of collection passed object considered long-living and been promoted to tured gen) and size (big object can be allocated in tenured).

  • Management API : memory pools question

    Hie,
    I have big issues when trying to find out the actual cycle of life of an object in memory pools. Does anybody have documentation about it ?
    What I kinda understood is :
    1. instantiation of a class : the object goes directly in the Eden Space mem pool
    2. a first run of gc processes this object (this first run of gc() is quite immediate after instanciation) :
    * object is still visible : gc() puts it in the Tenured Gen pool (? or in survivor space???)
    * object is not : there it's quite obscure, gc() randomly collects it...
    What I want to measure is the actual peak of memory heap (that is objects that are still visible and non-collectable).
    So far, i uses getPeakUsage() of the tenured gen pool, which seems to be quite correct...
    so here are my questions :
    * how often do gc() run on each memory pool ?
    * how do gc decide whether an object goes in 'survivor space' or in 'tenured gen'
    Thanks !

    1) There are two types of collecion:
    minor (newgen only)
    major (full)
    minor collection are rather frequently and fast, major are time consuming and rare. GC tries to adaptively set size of newgen to optimize overhead.
    use -XX:+PrintGCDetails switch
    2) This mostly based on object age (how much minor collection it has before, after number of collection passed object considered long-living and been promoted to tured gen) and size (big object can be allocated in tenured).

  • Custome module pool creation

    Hi All,
    I have a requirement to create a module pool for maintaining data for some custom tables I created in SAP.
    I'd like to ask what the quickest way to create a module pool for the above is. I have been able to create maintenance screens using the extended table maintenance tool but there is a requirement for a more user friendly holistic approach.
    Any helpful suggestions will be greatly appreciated.
    Regards,
    Andy.
    Moderator message - This is not the place to learn module pool programing. Please try to ask a specific question.
    Edited by: Rob Burbank on Apr 16, 2009 9:14 AM

    Do like below
    if ok_code  = 'MODI' .  " for your modify button
    call transaction ' you transaction name '.
    now
    if  sy-ucomm = 'SAVE' or 'EXIT' or 'BACK' or 'CANC' .
    call screen 'your basic screen no.'.
    endif.
    endif.
    reward if helpful

Maybe you are looking for