question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Out of memory after activating Blaze-Permission

See original GitHub issue

Description

After activating BP i get a OOM heap exception on a test. This tests writes about 70k records batched:


    Lists.partition(allPermissions, 1000).forEach(chunk -> {
      entityManager.flush();
      entityManager.clear();
      chunk.forEach(entityManager::persist);
    });

allPermissions is a Collection of PermissionCache` entries looking like this

@Entity
@Data
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
@NoArgsConstructor(access = AccessLevel.PRIVATE)
@AllArgsConstructor
public class PermissionCache
{
  @EmbeddedId
  @EqualsAndHashCode.Include
  PermissionCacheId permissionId = new PermissionCacheId();

  public PermissionCache(final Long spaceId, final Long uid)
  {
    this.permissionId.setSpaceId(spaceId);
    this.permissionId.setUid(uid);
  }
}

And the EmbeddedId is

@Data
@Embeddable
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
public class PermissionCacheId implements Serializable
{
  @EqualsAndHashCode.Include
  @Column(name = "space_id", columnDefinition = "INT(11)")
  private Long spaceId;

  @EqualsAndHashCode.Include
  @Column(name = "uid", columnDefinition = "INT(11)")
  private Long uid;
}

I’am using batched writes with

useServerPrepStmts=false&rewriteBatchedStatements=true on the JDBC URL and

spring.jpa.properties.hibernate.jdbc.batch_size=1000
# suppress inspection "SpringBootApplicationProperties"
hibernate.jdbc.batch_size=1000

In the properties

I understand that batch size can be one of the reasons here - but since that code has never thrown an OOM ever yet, and does so with BP, i suspect a memory leak we are yet not aware of

Expected behavior

Perform the same way as without BP

Actual behavior

OOM exception


  org.springframework.jdbc.datasource.init.UncategorizedScriptException: Failed to execute database script; nested exception is java.lang.OutOfMemoryError: Java heap space

  Caused by: java.lang.OutOfMemoryError: Java heap space

Full stacktace: https://dpaste.de/ociG

Steps to reproduce

Probably use the describe Entity with a simple JpaRepository (save/saveAll not overriden) Write arround 70k entries batched in one session

Environment

Version: 9.9-snapshot based on non-HEAD #846 JPA-Provider: hibernate 5.4.5 DBMS: mariadb10.3 Application Server: spring boot 2.1.7

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:24 (20 by maintainers)

github_iconTop GitHub Comments

2reactions
beikovcommented, Sep 21, 2019

In spring data 1.x CrudMethodMetadataPopulatingMethodInterceptor was implemented as singleton and I simply tried to do it like spring data did it. I’ll fix that.

0reactions
EugenMayercommented, Sep 21, 2019

This fixed this oom and nothing else broke on our side! Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Windows Error saying out of memory on a new laptop.... HP ...
Try increasing the virtual memory: Open search & enter Advanced system settings, once there choose Performance>Settings>Advanced>Virtual memory ...
Read more >
OMS Crashes After Startup with java.lang.OutOfMemoryError ...
Restarting OMS due to out of memory condition. Enabling java heap dumps will help Oracle Support diagnose this further. Java heap dumps can...
Read more >
How to Resolve the WordPress Memory Limit Error (2 Methods)
Option 1: Increase the PHP Memory Allocated to Your Website​​ It may seem simple, but sometimes the obvious solution is the best one....
Read more >
Out of Memory and Out of System Resources messages
We have identified an issue with older versions of Symantec Endpoint Protection causing Out of Memory and Out of System Resource messages and...
Read more >
Here are the ways to fix 'Google Chrome Is Out of Memory' error
1. Restart your device. 2. Update Google Chrome. 3. Clear the browser's cache.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found