Joey
Joey

Reputation: 2978

exception occurred while sending notification by JavaPNS

while sending push notification by JavaPNS, an exception occurred with below message.

Exception in thread "JavaPNS grouped notification thread in LIST mode" java.lang.OutOfMemoryError: Java heap space

I guess the reason is because of that I tried to send the notifications to too many users by 1 time.

public void send (List<Device> devices, Object keystore, String password, boolean production) {

       /* Prepare a simple payload to push */ 
        PushNotificationPayload payload = PushNotificationPayload.alert("Hello World!");


       /* Decide how many threads you want to create and use */ 
        int threads = 30;


       /* Start threads, wait for them, and get a list of all pushed notifications */ 
        List<PushedNotification> notifications = Push.payload(payload, keystore, password, production, threads, devices);


}

I put 73,889 device tokens to the List devices and received the exception.

Do you think I need to send the notification several times? Does anybody have an idea about sending notificaion to a lot of people?

Thank you!

Upvotes: 0

Views: 832

Answers (1)

idbill
idbill

Reputation: 362

I can think of 2 solutions to your problem:

1) send batches of ... say 20k

or

2) Increase your heap memory size

example: java -Xms512m -Xmx512m

(do a search...)

Upvotes: 1

Related Questions