Skip to Content

Machine Learning API in Cloud Application Programming Model

Hi all,

Has anyone tried to use the Machine Learning API in a hook function of your Java based Cloud Appication Programming Model Project in SAP Web IDE?

I try to use the code of the following blog in a function import of my CAP project.

https://blogs.sap.com/2018/07/29/production-ready-integration-of-sap-leonardo-machine-learning-foundation-services-with-an-sap-s4hana-side-by-side-extension-built-with-the-sap-s4hana-cloud-sdk/

Everytime I run the code, the service crashes on the invoke function and returns the following error:

---- SAP Metaspace Statistics (Non-Class Space) ---- MaxMetaspaceSize: 107372544. Metaspace Colaescation is ON. -- VirtualSpaceList -- 43 space(s). Non-Current Nodes: Used: 92160K, Comitted: 92160K, Reserved: 92160K. Current Space: Used: 980K, Comitted: 1024K, Reserved: 2048K. Total (current and noncurrent): Used: 93140K, Comitted: 93184K, Reserved: 94208K. Chunk Composition: special normal: used: 1 free: 0 special padding: used: 3 free: 5 special leftover: used: 0 free: 0 special coalesced: used: 0 free: 0 special split: used: 162 free: 38 small normal: used: 49 free: 353 small padding: used: 51 free: 194 small leftover: used: 0 free: 0 small coalesced: used: 1 free: 0 small split: used: 0 free: 0 medium normal: used: 1337 free: 0 medium padding: used: 0 free: 0 medium leftover: used: 0 free: 0 medium coalesced: used: 0 free: 0 medium split: used: 0 free: 0 humongous normal: used: 4 free: 0 humongous padding: used: 0 free: 0 humongous leftover: used: 0 free: 0 humongous coalesced: used: 0 free: 0 humongous split: used: 0 free: 0 -- Metaspaces -- 173 live Metaspaces. special Chunks: 73 non-current chunks: Used: 71K, Free: 1K. 93 current chunks: Used: 69K, Free: 23K. Total: 166 chunks: Used: 140K, Free: 25K. small Chunks: 25 non-current chunks: Used: 99K, Free: 0K. 76 current chunks: Used: 116K, Free: 187K. Total: 101 chunks: Used: 216K, Free: 187K. medium Chunks: 1333 non-current chunks: Used: 85286K, Free: 25K. 4 current chunks: Used: 107K, Free: 148K. Total: 1337 chunks: Used: 85394K, Free: 174K. humongous Chunks: 4 non-current chunks: Used: 4769K, Free: 1K. 0 current chunks: Used: 0K, Free: 0K. Total: 4 chunks: Used: 4769K, Free: 1K. Total: 1435 non-current chunks: Used: 90227K, Free: 28K. 173 current chunks: Used: 292K, Free: 360K. Total: 1608 chunks: Used: 90520K, Free: 388K. Accumulated Free Blocks: 26509 -- ChunkManager -- 43 special chunks, total size 43K. 547 small chunks, total size 2188K. 0 medium chunks, total size 0K. 0 homungous chunks, total size 0K. Resource exhaustion event. ResourceExhausted! (1/0)

Any idea what this means? Do I not have enough resources on my trial account?

Thank you in advance for your help.

Kr, Wouter

Add comment
10|10000 characters needed characters exceeded

  • Thank you all for helping!

    It works thanks to this setting in mta.yml:

    JBP_CONFIG_SAPJVM_MEMORY_SIZES:'metaspace:256m..'

    I was not able to set this is the correct answer because it was a reply on another answer.

    Kr, Wouter

  • Follow
  • Get RSS Feed

3 Answers

  • Best Answer
    Mar 11 at 02:57 PM

    Hi there,

    sounds like you are running out of "Metaspace" (a native memory region used by the Java Virtual Machine to manage Java objects). Please try to increase the metaspace size (current size is ~100MB) and restage your application:

    cf set-env <APP_NAME> JAVA_OPTS '-XX:MaxMetaspaceSize=256M'
    cf restage <APP_NAME>

    Does the application start fine this time?

    Best regards,

    Mitja

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 14 at 03:28 PM

    Would you mind sharing the log again, so I can check whether settings got picked up properly and if it's indeed the same issue?

    Cheers,

    Mitja

    Add comment
    10|10000 characters needed characters exceeded

  • Mar 18 at 10:00 AM

    Hi Wouter,

    I tried running the blog as described and it still works. I also tried changing the metaspace parameter in the manifest.yml file to 256mb and a ‘cf push’ changed that on the platform, too.

    Do you have a larger overall project which might impact the metaspace? Could you verify that the parameter got propagated from mta.yml to the JRE?

    Best,
    Georg

    Add comment
    10|10000 characters needed characters exceeded